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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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...
Explanation:

Input (i): 2000
- The input year is 2000.
- Since 2000 is divisible by 100, the first condition is met.
- Next, it checks if 2000 multiplied by 400 is equal to 0, which is false.
- Therefore, the output will be "Not a century year".

Input (ii): 1900
- The input year is 1900.
- 1900 is divisible by 100, so the first condition is satisfied.
- However, 1900 multiplied by 400 is not equal to 0.
- Hence, the output will be "Not a century year".

Input (iii): 1971
- The input year is 1971.
- 1971 is not divisible by 100, so the first condition is false.
- Therefore, it directly prints "Not a century year".
This code fragment is trying to determine if a given year is a leap century year by checking if the year is divisible by 100 and if the year multiplied by 400 is equal to 0. In the provided inputs, only years that are divisible by both 100 and 400 are considered as leap century years.
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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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) 1971? year int(input("Enter 4-digit year")) If (year % 100==0): if (year * 400 ==0) 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