Boolean Expression, Conditionals, Nested Conditionals
Hacks and notes on 5 and 7
isRaining = False
result = not(isRaining)
print(result)
grade = 75
# Has to be between 70 and 100
if grade > 70 and grade <= 100:
print("You passed the quiz")
Logical Operator
- A logical operator is a symbol or word used to connect two or more expressions Selection
- The specific block of code that will execute depending on the algorithm condition returning true or false. Algorithm
- A specific task that is completed with the use of instructions Conditional Statement / If-Statement:
- A statement that affects the sequence of control by executing certain statements depending on the value of a boolean (true or false).
SoccerMinutesPlayed = 48
if SoccerMinutesPlayed > 40:
print("you played over half the soccer game, congradulations!")
else:
print("You need to train more")
# Adding another variation to the hack
import random
a_list = [27, 32, 96,]
random.shuffle(a_list)
a_list[0]
if a_list == 27:
print(result)
else:
print('your number is not 27')
# If statement
import random
a=random.randint(1,100)
print(a)