# Popcorn Hack 1
user1 = int(input("Enter your first number"))
user2 = int(input("Enter your second number"))
if user1 > user2:
print("Your first number is bigger")
elif user1 < user2:
print("Your second number is bigger")
else:
print("Both numbers are equal")
Your first number is bigger
#Popcorn Hack 2
weather= int(input("Type 1 if it is sunny, Type 2 if it is raining"))
temperature = int(input("Type 1 if it is hot, Type 2 if it is cold "))
if weather and temperature == 1:
print("Todays a good day to go the beach!")
else:
print("Today is a bad day to go the beach. ")
Todays a good day to go the beach!
#Popcorn Hack 3
A = True
if not A:
print("A if alse")
if not False:
print("A is true")
A is true
#Popcorn Hack 4
print("test 1:")
A = True
B = False
if A ^ B:
print("xored")
else:
print("not xored")
print("test 2:")
A = False
B = False
if A ^ B:
print("xored")
else:
print("not xored")
test 1:
xored
test 2:
not xored
Homework
#Hack 1
#XNOR Table
A | B | Output |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
#Hack 2
#Logic Gate 1: Or
A = True
B = False
if A or B:
print("True Dat")
True Dat
# Logic Gate 2: AND (with purpose)
weather= int(input("Type 1 if it is sunny, Type 2 if it is raining"))
temperature = int(input("Type 1 if it is hot, Type 2 if it is cold "))
if weather and temperature == 1:
print("Todays a good day to go the beach!")
else:
print("Today is a bad day to go the beach. ")
Todays a good day to go the beach!
#Logic Gate 3: XOR (with purpose)
one= int(input("Type 1 if you want to watch a movie, Type 2 if you want to do chem homework"))
two = int(input("Type 1 if you want to play fortnite, Type 2 if you want to write an essay"))
if one ^ two:
print("Todays a good day to have some fun!")
else:
print("BOoo!")
Todays a good day to have some fun!
#Hack 3 Bob Grading stuff
# i used two logic gates (and twice)
isComplete = {'Student 1': 1, 'Student 2': 1, 'Student 3': 0, 'Student 4': 1, 'Student 5': 0, 'Student 6': 1}
isOnTime = {'Student 1': 1, 'Student 2': 0, 'Student 3': 0, 'Student 4': 1, 'Student 5': 1, 'Student 6': 1}
homework = {'Student 1': '', 'Student 2': '', 'Student 3': '', 'Student 4': '', 'Student 5': '', 'Student 6': '' }
for student in isComplete and isOnTime:
if (isComplete[student] and isOnTime[student]):
print("Complete")
homework[student]='Complete'
else:
print("Incomplete")
homework[student]='Incomplete'
print(homework)
## Example output: {'Student 1': 'Incomplete', 'Student 2': 'Incomplete', 'Student 3': 'Incomplete', 'Student 4': 'Incomplete', 'Student 5': 'Incomplete', 'Student 6', 'Complete'}
## Extra: Format the output nicely
Complete
Incomplete
Incomplete
Complete
Incomplete
Complete
{'Student 1': 'Complete', 'Student 2': 'Incomplete', 'Student 3': 'Incomplete', 'Student 4': 'Complete', 'Student 5': 'Incomplete', 'Student 6': 'Complete'}