Day 2
Logic Gates
AND Gate
Only TRUE when TRUE & TRUE

OR Gate
TRUE when either is TRUE

NOT Gate
Opposite of everything

NAND Gate
Not and

NOR Gate
Not or
XOR Gate
Exclusive or gate

Two digit adder

Boolean in Python
Equal
1 == 1 # compares two things to each other x = 1 # assigns the value 1 to the variable x
If statements
if condition: # if the condition is true do something # do this stuff
Else if statements
elif condition: # done if the "if" statement is false # check if the condition is true do something # do this stuff
Else statements
else: # if all the if and elif statements are false do this stuff
Loops
While loop
while condition: # while this condition is true do this # do this stuff
- NOTE: Use while true with extreme caution, generally not recommended unless you are working with physical components
- use "break" to exit a while loop, or change the condition to be false
For loop
for x in range (y,z): do stuff # repeats the "do stuff" for z-y times
- create an iterator, and the iterator increases by 1 each time
- repeat as long as iterator is in range
- used to specify if you want to repeat something for a set amount of times
Sample solution to the final game
The full sample solution can be found here on our class GitHub repository.
Homework
Challenge you parents to play the game, then ask for their feedback.