Unit 1: Introduction to Programming
Lab 1: Click Alonzo Game
1.1.4: Sprites and Costumes
The Alonzo character is named after Alonzo Church, a major contributor to early computer science. In this project, there are three objects related to Alonzo:
- One is a sprite, which is like an actor on the stage who knows how to do many different things, such as walk around the stage and speak the lines of the play.
- The other two are costumes, picture that can be "worn" by a sprite.
The transparency of an image is how much you can see what's behind it. For example, here is the Alonzo sprite shown with three different transparencies (which have been set using the
ghost effect block).
Lab 2: Gossip
, and Concatenation
What does "ordered" mean?
A list is an ordered sequence of items. You've seen this example:
It doesn't mean that the items have to appear in alphabetical
or numeric order. It just means that
is a different list from
- The items of this list are strings. A string is a sequence of characters (letters, digits, punctuation, etc.). A substring is just a piece of some existing string. For example, "Hanna," "anna", and "nnah" are each substrings of the string "Hannah." (The empty string as well as the original string are both also substrings.)
- To concatenate strings means to make a bigger string by connecting two or more smaller strings. In Snap!, the block lets you concatenate strings.
The process of testing, finding problems, and fixing them is called debugging.
, and Commands
A procedure is a named sequence of instructions that may take inputs and may report a value. Some languages call procedures methods or functions. Here are two types of procedures you have seen in Snap!:
Reporters have an oval shape. They report a value.
Commands have a jigsaw puzzle shape. They tell the computer to do something without reporting a value.
Lab 3: Modern Art with Polygons
An algorithm is a sequence of steps that are usually performed by a computer. The algorithm doesn't have to be written in any particular programming language or even in a programming language at all; you can write your algorithm in English or any other human language. Some people call an algorithm written in human language pseudocode. Once you know the steps that the computer will take, you can code your algorithm in the programming language of your choice.
What's the purpose of "pseudocode"? Why write an algorithm vaguely in English when you could write it precisely in Snap!? If you were programming in a punctuation-heavy language, designing your program in pseudocode would help you focus on the important ideas instead of on details like quotation marks and semicolons. But pseudocode isn't as necessary with a language like Snap!, and pseudocode can make it easy for you to fall into wishful thinking about what the computer is capable of (such as writing "Pick tomorrow's winning lottery numbers" or "Here's the melody; write the harmony").
: What's an input? Parameter
A parameter (or formal parameter) is the input name, such as number of branches. The input name is set in the block definition. It never changes.
An argument (or actual argument) is the input value, such as 6 for a hexagonal pinwheel. The input value is given each time the block is run; it can be a different value each time.
We use the word "input" both for parameters (input names) and for arguments (input values).
Computer scientists describe a repeating program structure as looping, repetition, or iteration.
The code can be repeated
forever, a specific number of times (such as when using
repeat), or until something specific happens (such as when using
repeat until as you'll see in Lab 5).
Lab 4: Protecting Your Privacy
Personally identifiable information (PII) is information that can let others figure out who you are and possibly get more information like your Social Security number, age, race, phone number(s), medical information, financial information, or biometric data (such as your thumbprint or face scan).
Lab 5: Follow the Leader
When a program keeps running forever, that's called an infinite loop.
CRD-2.B.2, AAP-2.B.2, AAP-2.B.6
A code segment is a sequence of connected instructions that carry out a purposeful action, such as the one pictured on the left, which animates a conversation. The instructions in the code segment are carried out in order, from top to bottom.