unless they are also divisible by 400. Write a program that asks the user for a year and prints out whether it is a leap year or not .
This code first prompts the user for a year and stores it in the variable year
. It then uses an if-elif-else statement to check if the year is divisible by 400, 100, or 4. If the year is divisible by 400, it prints a message saying that the year is a leap year. If the year is divisible by 100 but not by 400, it prints a message saying that the year is not a leap year. If the year is divisible by 4 but not by 100, it prints a message saying that the year is a leap year. If the year is not divisible by 4, it prints a message saying that the year is not a leap year.
You could name this code "leap_year_checker" or something similar.
Here is an example of the output of the code I provided:
Enter a year: 2000
2000 is a leap year
This is what the user would see if they entered 2000 when prompted for the year. The year 2000 is a leap year because it is divisible by 400.
Here is another example of the output:
Enter a year: 1900
1900 is not a leap year
In this example, the user entered 1900 as the year. The year 1900 is not a leap year because it is divisible by 100 but not by 400.
Note that the output will vary depending on the year the user inputs. If the year is divisible by 400, the program will print a message saying that it is a leap year. If the year is divisible by 100 but not by 400, the program will print a message saying that it is not a leap year. If the year is divisible by 4 but not by 100, the program will print a message saying that it is a leap year. If the year is not divisible by 4, the program will print a message saying that it is not a leap year.
0 Comments