Narrated by Horst
draw_tree(225, 35)
draw_tree(420, 45)
draw_house(720, 60)
draw_snow_person(300, 20)
How to use variables (this chapter)
How to write expressions (this chapter)
How to create our own functions (the next two chapters)
temperature_in_celsius
tree_position_1
tree_position_2
car_speed
number_of_children
simpson
temperatueInCelsius - Uses capital letters. Keep it lower case and use underscores.
x - Too short, and not descriptive.
Smith - Starts with a capital letter.
tree position - Can’t use spaces
4runner - Can’t start with a number
Variables that don't change are constants
They should be in all upper-case
PI = 3.14159
SCREEN_WIDTH = 800
Operator | Description |
---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
** | Exponentiation |
/ | Division |
// | Integer division (always rounds down) |
% | Modulus (division remainder) |
Operator | Description |
---|---|
= | Assignment |
+= | Increment |
-= | Decrement |
*= | Multiply |
/= | Divide |
average = 90 + 86 + 71 + 100 + 98 / 5
average = (90 + 86 + 71 + 100 + 98) / 5