Now that we have the if statement, let's expand on its flexibility by introducing two complementary statements. Since you already read Chapter 3 for the last lecture, none of this should be new!
You should have read it already, but today's topic is in Chapter 3 of the textbook.
We will discuss and learn about:
num = input("What is the temperature outside? ")
num = int(num)
if num <= 32:
print("Freezing cold!")
elif num < 212:
print("Solid.")
else:
print("Like a gas!")
# Convert date formats.
# INPUT: 2020 March 6
# OUTPUT: 03/06/20
#
year = int(input("Year (XXXX)? "))
mon = input("Month (name)? ")
day = int(input("Day? "))
if( mon == 'January' ):
month = '01'
elif( mon == 'February' ):
month = '02'
elif( mon == 'March' ):
month = '03'
elif( mon == 'April' ):
month = '04'
elif( mon == 'May' ):
month = '05'
elif( mon == 'June' ):
month = '06'
elif( mon == 'July' ):
month = '07'
elif( mon == 'August' ):
month = '08'
elif( mon == 'September' ):
month = '09'
elif( mon == 'October' ):
month = '10'
elif( mon == 'November' ):
month = '11'
else:
month = '12'
# 2020 -> '20'
year = year % 100
if year < 10:
year = '0' + str(year)
else:
year = str(year)
# 8 -> '08'
if day < 10:
day = '0' + str(day)
else:
day = str(day)
print(month + '/' + day + '/' + year)