exercises 1-5
- variables: stores a piece of data and gives it a specific name
- my_variable = 10
- my_variable (variable) now stores the number 10
- numbers are one data type used in programming
- another data type is called a boolean
- like a light switch, it only has two values (True or False)
- variables can store booleans (a = True)
- you can change the value of variables by reassigning it
exercises 5-10
- whitespace is used to structure code and must be properly formatted
- indentation error: expected an indented block
- you'll get this error whenever your whitespace is off
- you should indent your code with four spaces (__why?__)
- interpreter: runs code line by line and checks for error
- comments: use a pound sign before the comment so that python will not try to run the comment as code
- comments are good to add so you remember what you were doing and if you are collaborating
- for multi-line comments, use triple quotation marks
- math: you can add, subtract, divide, multiply
exercises 10-13
- you can combine math with data types
- to use exponents:
- eight = 2 ** 3
- python squared means (python ** 2)
- modulo: returns the remainder from division
- ex: 3 % 2 returns 1, because 2 goes into 3 evenly once with 1 left over
nov 28 2014 ∞
apr 19 2015 +