Exercises – Basic programming concepts in Scratch

Visit this page with a very simple game.

You should first play through it twice.

  1. On the first time, press the green flag. When asked your name, type in ‘Lady Gaga’.
  2. On the second time, press the green flag again. When asked your name and age, type in your real name and age (or fake ones, as long as you don’t use Lady Gaga’s name).

Then go here.. This page shows the code underlying the game.

Part A. Complete the questions below. Have one representative in your group do the clicking, while others have the code open.

To help you, here are some useful definitions:

  • Assertion (or statements in mathematics): Something that can be true or false. e.g. 1 + 1 = 3 (false), Raccoons are mammals (true).
  • Term: Something that can serve as an argument of an operator. In arithmetic these are generally quantities; in programming this can also be character strings, True/False values, etc.
  • Control statement: A statement that controls whether certain commands are performed, generally by checking whether some condition is true.
  • Commands: An instruction for a computer to perform some task. Note that although terms are commands in many programming languages, they are not in Scratch.

  • Operators: Anything that takes arguments which are its terms and does something with them.
  • Relational operators: An operator that compares two terms.
  • Reciprocal operators: An operator where you can change the order of the terms and the result will be the same.
  • Functions: A special kind of operator that does more complicated things after taking arguments. In programming, it usually contains a bunch of other commands that are performed whenever the function is used.
  • Variables: Terms that can be set to different values. For example, x in algebra.
  • Constants: Terms that have a fixed value. For example, 14 or pi.

Part B.

  1. What are some examples of discreteness and combinatorialism in Scratch code? [Hint: Think about the language used in Scratch code, but also think about the shapes. If you look at the exercises above, is there anything that all elements in a particular box have in common?]
  2. What are some examples of arbitrariness in Scratch code? [Hint: What represent, terms, variables, constants, commands, and statements in Scratch?]
  3. What are some examples of abstractness in Scratch code? [Hint: Looking at the first block of code, which line clearly does much more complicated things than the form of the code itself lets on?]
  4. Are there any aspects of iconicity in Scratch code that you can find? How is it represented in other programming languages? [Hint: In another programming language, the last line might be written as say(join(join(sentencepart1, sentencepart2), “!”)).]

[Originally created for LING 15 with Prof Bob Kennedy.]