Question: Determining a leap year This program first prompts the user to enter a year as an int value and checks if it is a leap

Determining a leap year
This program first prompts the user to enter a year as an int value and checks if it is a leap year.
A year is a leap year if it is divisible by 4 but not by 100, or it is divisible by 400.
Use input() to take the user input (the year, i.e.2016) and convert it with int()
Use % to see if a number x is divisible by an other number y, if x%y returns 0, then x is divisible by y
Check if the year is divisible by 4 AND not divisible by 100
OR check if the year is divisible by 400.
Use print()
Exercise 2:
Display leap years
Write a program that displays, ten per line, all the leap years in the twenty-first century (from year 2001 to 2100). The years are separated by exactly one space.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!