Python Refresher

If Statements and Comments

Make an if-else statement where if year is between 2000 and 2099, then print out:

Welcome to the 21st century!

Else print out:

You are before or after the 21st century

                year = 1830
            

Solution

                    year = 1830 

if 2000 <= year < 2100:
    print("Welcome to the 21st century!")
else:
    print("You are before or after the 21st century")
                

Here's some courses you might like: