0% found this document useful (0 votes)
7 views

Algorithms and Programming (CS1)_ Lesson 1 - Syntax & Sequences

The document outlines the principles of algorithms and programming, emphasizing the integration of algorithms and abstraction in creating programs. It covers computational thinking practices, including solution design, code analysis, and debugging, while introducing key programming concepts such as statements, code segments, and algorithms. Additionally, it provides an overview of the CodeCombat platform, where learners can practice coding through quests and activities.

Uploaded by

gexzcheong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Algorithms and Programming (CS1)_ Lesson 1 - Syntax & Sequences

The document outlines the principles of algorithms and programming, emphasizing the integration of algorithms and abstraction in creating programs. It covers computational thinking practices, including solution design, code analysis, and debugging, while introducing key programming concepts such as statements, code segments, and algorithms. Additionally, it provides an overview of the CodeCombat platform, where learners can practice coding through quests and activities.

Uploaded by

gexzcheong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Today’s Big Idea

Algorithms and Programming (AAP):


Programmers integrate algorithms and abstraction to create programs for
creative purposes and to solve problems. Using multiple program statements in a
specified order, making decisions, and repeating the same process multiple times
are the building blocks of programs. Incorporating elements of abstraction, by
breaking problems down into interacting pieces, each with their own purpose,
makes writing complex programs easier. Programmers need to think
algorithmically and use abstraction to define and interpret processes that are used
in a program.
Today’s Computational Thinking
Practices
Computational Solution Design:
● 1.A: Investigate a situation, context, or task.
● 1.B: Determine and design an appropriate method or approach to achieve the purpose.
● 1.D Evaluate solution options.

Algorithms and Program Development:


● 2.A: Represent algorithmic processes without using a programming language.
● 2.B: Implement an algorithm in a program.
Today’s Computational Thinking
Practices Continued
Code Analysis:
● 4.A: Explain how a code segment or program functions.
● 4.B: Determine the result of code segments.
● 4.C Identify and correct errors in algorithms and programs including error discovery
through testing.
CodeCombat
Introduction to Computer Science

Quest #1
Syntax & Sequences
Let’s Review…

CODING CONCEPTS
1 What did we talk about last time?

GUIDED PLAY AND INDEPENDENT PRACTICE


2 What activities are you still working on?

CHECK-IN & CONCEPT REVIEW


3 Are you having trouble with a concept?

COMPLETE QUESTS
4 Are there any quests you want to review?
Quest #1
By the end of my quest, I
will be able to…

💎 Write my first computer


program.
💎 Describe the output
produced by an
algorithm.
💎 Debug a simple
program.
Programs

Image Source
Program (Software)
A set of instructions that tells our computer to
do something.
Statements & Code Segments
Statement: A line of code
that tells a computer to
perform a specific action.
Code Segment: A group of
statements that work together
to perform a specific action.

All programs are made up of statements & code segments!


Algorithms
Algorithm
A sequence of instructions that
can be used to solve a problem.

Sequencing is the act of


completing the action described
by a statement in the order in
which it is given within a
program.
Execution is top to bottom, left
to right.
Decomposition
You can solve a complex problem by breaking it down into
smaller subgoals & steps.
What are the subgoals for making a
grilled cheese sandwich?

Subgoal 1: Build
- Grab 2 slices of bread.
- Cut 3 slices of cheese.
- Put slices of cheese in between
slices of bread…

Subgoal 2: Grill
- What are the steps?
Warm-Up
Write down a sequence of steps (algorithm) to help the hero
collect all the coins. What order will these statements be
executed?

1. Move up
2. Move right
3.
4.
5.
6.
7.
8.
Warm-Up: Solution

1. Move up
2. Move right
3. Move up
4. Move right
5. Move down
6. Move right
7. Move down
8. Move right
To the Dungeon!

Let’s put these


concepts into
action!
Overview of CodeCombat IDE
5
3
1

1. Level goals and completion status 4. The editor window is where you will write your
2. Game controls (play/pause, volume, clock slider, zoom) own code. There is an autocomplete feature!
and select object properties 5. Click “HINTS” for more information if you get
3. Statements and code segments available in the level; click stuck.
on any method to learn how to use it 6. Click “RUN” to test your code. Test often!
Game Recap: Dungeons of Kithgard

Let’s watch a video


to learn more
about syntax.

Starter Code 👀
Python
Concept Video: Basic Syntax
Syntax - Calling Methods
This statement calls a method!
A method call contains three
pieces of information: Python Syntax:

1. object: The hero. # Comments will include


# instructions and hints!
2. method: The action the
object method
object performs.
hero.moveRight()
3. argument: A value that
optional arguments
describes how many steps
the hero takes to the right.

Python
Program Documentation

# Document your programs by Documentation: The written


# adding comments to help descriptions we include within
# maintain, extend, and our programs to explain how
# improve upon your
code segments work. We often
# programs!
accomplish this by writing
hero.moveRight() comments in our programs.

It is important to document your programs all the time and at multiple


stages of the development process!

Python
Finding and Fixing Errors
You’re going to make mistakes. That’s a very NORMAL part of coding, even for
experts. Finding and fixing errors (debugging) is an important part of
programming. Consider using the following tools when debugging your
programs:

● Error messages We are going to


practice reading error
● Comments messages in CS1!
● hero.say() or print()
● Inputs and outputs
● Tracing tools
● Debuggers
● Unit tests
Activity: Debugging
The following program is intended to make the hero collect all
of the gems. However, it does not work as intended.
1.
1 Where is the error?
2.
2 How would you fix this mistake?

Python
Independent Practice
Log into CodeCombat
https://codecombat.com/

Play Levels
CS1 Levels 1-3b, CC Careful Steps

Need Help?
Ask a friend or AI!
Key Terms (1/3)
● Program: A set of instructions that tells our
computer to do something. Also known as software.

● Statement: A line of code that tells our computer to


perform a specific action.

● Code Segment: A group of statements that work


together to perform a specific action.

● Algorithm: A sequence of instructions to solve a


problem.

● Sequencing: The act of completing the action


described by a code statement in the order in which
it is given within a program.
Key Terms (2/3)
object method

hero.moveUp()
argument

● Object: A bundle of information that you can access and


manipulate using methods, like a character in your
game.

● Method: A set of instructions that an object can follow


in order to perform an action.

Call: A special line of code that tells our computer to


run a method.

● Argument: Part of a method that specifies how the


action is performed.
Key Terms (3/3)
● Syntax: The rules of a computer language that govern
how lines of code are written (e.g. structure,
capitalization, and punctuation).

● Comments: The descriptions added to a program that


help programmers understand what a program does.
Here is how we write comments in Python:

# Comment in Python

● Debug: The act of finding and fixing problems within a


program.

● Execute: The act of our computer reading and


completing a statement in a program. Computers
generally execute programs from top to bottom.
Any Questions? 5

4
6

1
Wrap-Up 1
Explain how to play
CodeCombat to someone
who has never played
before. Your answer should
include the terms
“algorithm”, “method”, and
“call” for it to be considered
correct.
Wrap-Up 2
There’s a problem with the
following algorithm:

What is wrong? What would


you do to fix this problem?
Python
Wrap-Up 3
Consider the following
algorithm:

Describe what would happen if


you were to run this program. It
may help to examine the
dungeon to the right.
Python
Wrap-Up
Add your own
formative question.

You might also like