3.5 to 3.7 Hacks
isWeekend = False
result = not(isWeekend)
print(result)
score = 56
# Has to be between 50 and 100
if score > 50 and score <= 100:
print("You passed")
distance = 3
speed = 10
if distance < 2 or speed > 4:
print("You won!")
Key Terms
- Selection: The specific block of code that will execute depending on the algorithm condition returning true or false.
- Algorithm: "A finite set of instructions that accomplish a specific task."
- Conditional Statement / If-Statement: A statement that affects the sequence of control by executing certain statements depending on the value of a boolean.
x = int(input())
if x % 2 == 0:
print("thats an even number")
else:
print("thats an odd number")
print("are you going to school tommorow?")
reply = input("yes or no")
if reply == "yes":
print("great")
if reply == "no":
print("oh no")
print("what quarter of the year are you in?")
reply = input("1, 2, 3 or 4")
if reply == "1":
print("Then its January, February or March")
if reply == "2":
print("Then its April, May or June")
if reply == "3":
print("Then its June, August or September")
if reply == "4":
print("Then its October, November or December")