UPSC Exam  >  UPSC Questions  >  What will be the output of the following code... Start Learning for Free
What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))
if (year % 1000):
if (year X 4000):
print (LEAP century year")
else:
print (Not century year")?
Most Upvoted Answer
What will be the output of the following code fragment if the input gi...
Analysis of the Code Fragment:
The given code fragment takes a 4-digit year as input and checks whether it is a leap century year or not based on certain conditions.

Input 1: 2000
- The input year is 2000.
- 2000 is divisible by both 1000 and 4000, so the condition (year % 1000) will be true.
- However, the condition (year X 4000) will be false as 2000 is not divisible by 4000.
- Therefore, the output will be "Not century year".

Input 2: 1900
- The input year is 1900.
- 1900 is divisible by 1000 but not by 4000, so the first condition will be true but the second condition will be false.
- Hence, the output will be "Not century year".

Input 3: 1991
- The input year is 1991.
- 1991 is not divisible by 1000, so the first condition will be false.
- Since the first condition itself is false, the code will not check the second condition.
- Therefore, the output will be "Not century year".
In conclusion, the code fragment is designed to check if a given year is a leap century year by verifying if the year is divisible by both 1000 and 4000. Based on the input years provided, the output will be either "LEAP century year" or "Not century year" accordingly.
Explore Courses for UPSC exam

Top Courses for UPSC

What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")?
Question Description
What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")? for UPSC 2024 is part of UPSC preparation. The Question and answers have been prepared according to the UPSC exam syllabus. Information about What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")? covers all topics & solutions for UPSC 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")?.
Solutions for What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")? in English & in Hindi are available as part of our courses for UPSC. Download more important topics, notes, lectures and mock test series for UPSC Exam by signing up for free.
Here you can find the meaning of What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")? defined & explained in the simplest way possible. Besides giving the explanation of What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")?, a detailed solution for What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")? has been provided alongside types of What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")? theory, EduRev gives you an ample number of questions to practice What will be the output of the following code fragment if the input given is (1) 2000 (ii) 1900 (iii) 1991 ? year int(input("Enter 4-digit year"))if (year % 1000):if (year X 4000):print (LEAP century year")else:print (Not century year")? tests, examples and also practice UPSC tests.
Explore Courses for UPSC exam

Top Courses for UPSC

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev