100k views
2 votes
Write an if-else statement with multiple branches.

If year is 2101 or later, print "Distant future" (without quotes). Otherwise, if year is 2001 or greater, print "21st century". Otherwise, if year is 1901 or greater, print "20th century". Else (1900 or earlier), print "Long ago".

Sample output with input: 1776

What am I doing wrong here!!!!!!
I've tried it with =>
and just >

It isn't running the final submission

Testing with input: 1901
Output differs. See highlights below.
Your output
Long ago
Expected output
20th century

Write an if-else statement with multiple branches. If year is 2101 or later, print-example-1
User Erwin
by
4.7k points

2 Answers

1 vote

Answer:

Code below

Step-by-step explanation:

year = int(input())

if year >= ( 2101):

print("Distant future")

elif year >= (2001):

print("21st century")

elif year >= (1901):

print("20th century")

elif year <= (1900):

print("Long ago")

else:

print("No data exist for that year")

User Humberd
by
4.1k points
5 votes

Answer:

This program is written in python. The complete code with detail description is given below in explanation section.

Step-by-step explanation:

year = int(input("Enter Year:"))

if year > 2101:

print("Future Distant")

elif year > 2001:

print("21st Century")

elif year > 1901:

print("20th Century")

elif year <1900:

print("Long Ago")

else:

print("No data exist for that year")

.......................................................................................................................

this code run successfully according to requirement as asked in question.

User Pokemzok
by
4.3k points