DLT:
  • use timer blocks and keyboard controls to increase interactivity and control over actors.
  • Use Python commands to solve puzzle modules
  • Identify patterns in their code
  • Use "for" loops to reduce lines of code
  • Use arithmetic operators to add, subtract, multiply, and divide values
  • Apply coding knowledge to nest multiple "for" loops inside each other

Vocabulary:
  • Loop: A loop allows you to execute the same code a number of times.
  • "For" Loop: There are many types of loops, including the "for" loop. This loop has a counter (often called "i") that counts from the starting number to the ending number, increasing or decreasing the counter every time it executes the code. The "for" loop allows you to execute a set of code a certain predetermined number of times. The "for" loop in Python has the following syntax:

  • Indentation: To make your code more readable (for anyone else who needs to read or add to your code, as well as your future self debugging your code), it’s very helpful to indent properly. Indentation is NOT optional in Python because it is required to show the structure of code, differentiating between code that lies inside loops, functions, or conditionals and the code that lies outside them. Other languages like JavaScript use curly brackets to show the structure of code, so in these languages, indentation is technically optional but highly recommended. In Python, you must indent properly. We recommend using four spaces to indent.
  • Arithmetic Operator: For many computer programs, you will need to perform arithmetic operations on numbers. These are much like the operators you have in math, but there is a specific way you need to write them so that the computer recognizes them. For example, 9 squared can be written as "9**2"
  • Nested Loop: In Python, when you add a loop inside of a loop, this is called "nesting." The loops are referred to as the outer and inner loops. Nesting two "for" loops can allow you to do very interesting things, such as iterate over all the cells in a two-dimensional grid.
  • Modulus: The modulo operator (%) returns the remainder when one number is divided by another. Note: The modulus operator can be useful to find out if a number is divisible by another number if the modulus returns 0. For example, if "x = 8," then "x % 4" is 0. You can also use the modulo operation to check whether a number is odd or even. For example, if "(x % 2) == 0," then "x" is an even number. Otherwise, "x" is an odd number.

Activity:
  • Tynker 202: Timers - In previous lessons we learned how to apply impulses and keyboard controls to cannonballs but we haven’t had a lot of control over the strength of the shots. In this lesson we’re going to learn how to make precise shots using timer blocks and keyboard controls.

  • Tynker Python: Loops and Patterns (do in web browser not app)- In this lesson, you will learn about loops, one of the most useful programming constructs. Loops allow you to repeat lines of code multiple times. Later in this lesson, you will explore how you can programmatically decide how long you want to run a "for" loop based on a variable in your code. As you start using loops and conditionals, you will need to pay attention to how you are writing your code. If you’re trying to debug a program double-check your indentation! Due by the end of class. Remember to access through a web browser not the app.
As you work through the modules, check that you…
      • Place one command on a line
      • Spell the command correctly
      • End the command with open and close parentheses