if num<5:
print('Num less than 5')
elif 5<= num <=9:
print('Num between 5 and 9')
else:
print('Num more than 9')
if foo == 'abc' and bar == 'bac' or zoo == '123':
# do something
# if statment
#'if' gives condition in statement to make program more efficient.
a=10
b=5
if a%b==0:
print('true')
output:
true
Num1=float
Num2=float
Ans=float
operator=int
print("These are the following operations available:
, 1 for addition.
2 for subtraction.
3 for multiplication.
4 for division.")
operator = int(input("Enter the operator you wish to use"))
Num1 = float(input("Please enter your first number:"))
Num2 = float(input("Please enter your second number:"))
if operator ==1:
Ans == Num1 + Num2
else:
if operator ==2:
Ans == Num1 - Num2
else:
if operator ==3:
Ans == Num1 * Num2
else:
if operator ==4:
Ans == Num1 / Num2
print("Your answer is: %f.2", Ans)
x = 1; y = 1
if x == 1 or y == 1:
print(x, y)
# 1 1
weather == "Good!" or weather == "Great!":
# Or the following
weather in ("Good!", "Great!"):
def e(x):
if x == "Sunny" and x == "sunny":
print('Remember your sunglasses!')
elif x == "Rainy" and x == "rainy":
print('Do not forget your umbrella!')
elif x == 'Thunderstorm' or x == 'thunderstorm' or x =='Stormy' or x == 'stormy':
print('Stay Home!')
x = input('What is the weather?')
person = input("Nationality? ")
if person == "french" or person == "French":
print("Préférez-vous parler français?")
if person == "italian" or person == "Italian":
print("Preferisci parlare italiano?")
if num==5:
print("Num equal to 5")
elif num > 5:
print("Num more than 5")
else:
print("Num smaller than 5 but not equal to 5")
boolean1 = (1 != 1)
boolean2 = (2 + 2 == 5)
boolean3 = (1 == 1)
if (boolean1):
print("Boolean one is true")
elif (boolean2):
print("Boolean two is true")
else:
print("Boolean three may, or may not be true")