2026fa_cse160/lecture20261110/if/if02.py

27 lines
410 B
Python

# if statement example
if 22 > 7:
print("22 is greater than 7")
print("A better method to define the code ...")
# Use variables in the if statement and print
data1 = 22
if data1 > 7:
print(f"{data1} is greater than 7")
# Or this form
print("And another method to define the code ...")
data1 = 22
data2 = 7
if data1 > data2:
print(f"{data1} is greater than {data2}")
print("Program ended")