Write a program that accepts a positive integer that represents a year, and prints whether that year is a leap year or not. If the year is a leap year, it should print output similar to "2000 is a Leap Year". If not, it should print output similar to "2001 is not a Leap Year".
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 are not leap years, but the year 2000 is. - USNO
Write a program that accepts a positive integer that represents a year...
# Load required modules
import sys
Write a program that accepts a positive integer that represents a year...
# Load required modules
import sys
If an argument is present
we are reading from a file
specified in sys.argv[1]
if len(sys.argv) > 1:
reader = open(sys.argv[1])
If no argument, read from stdin
else:
reader = sys.stdin
-=-=-=-=- MORE CODE GOES HERE -=-=-=-=-
Write a program that accepts a positive integer that represents a year...
# Load required modules
import sys
If an argument is present
we are reading from a file
specified in sys.argv[1]
if len(sys.argv) > 1:
reader = open(sys.argv[1])
If no argument, read from stdin
else:
reader = sys.stdin
# -=-=-=-=- MORE CODE GOES HERE -=-=-=-=-
Write a program that accepts a positive integer that represents a year...
Write a program that accepts a positive integer that represents a year...
year = int(reader.readline())
Write a program that accepts a positive integer that represents a year...
year = int(reader.readline())
Write a program that accepts a positive integer that represents a year...
year = int(reader.readline())
if year <= 0:
print("Error")
else:
# more code here
Write a program that accepts a positive integer that represents a year...
year = int(reader.readline())
if year <= 0:
print("Error")
else:
# more code here
Every year that is exactly divisible by four is a leap year, except...
year = int(reader.readline())
if year <= 0:
print("Error")
else:
# more code here
Every year that is exactly divisible by four is a leap year, except...
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
else:
# not divisible by 4
print("no")
Every year that is exactly divisible by four is a leap year, except...
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
else:
# not divisible by 4
print("no")
...except for years that are exactly divisible by 100, but...
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
else:
# not divisible by 4
print("no")
...except for years that are exactly divisible by 100, but...
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...except for years that are exactly divisible by 100, but...
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...but these centurial years are leap years if they are exactly divisible by 400.
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...but these centurial years are leap years if they are exactly divisible by 400.
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...but these centurial years are leap years if they are exactly divisible by 400.
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
if year % 400 == 0:
# divisible by 4 and 100 and 400
print("yes")
else:
# divisible by 4 and 100 not 400
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...but these centurial years are leap years if they are exactly divisible by 400.
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
if year % 400 == 0:
# divisible by 4 and 100 and 400
print("yes")
else:
# divisible by 4 and 100 not 400
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...positive integer that represents a year...
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400.
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
if year % 400 == 0:
# divisible by 4 and 100 and 400
print("yes")
else:
# divisible by 4 and 100 not 400
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...positive integer that represents a year...
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400.
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
if year % 400 == 0:
# divisible by 4 and 100 and 400
print("yes")
else:
# divisible by 4 and 100 not 400
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...positive integer that represents a year...
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400.
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
if year % 400 == 0:
# divisible by 4 and 100 and 400
print("yes")
else:
# divisible by 4 and 100 not 400
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...positive integer that represents a year...
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
if year % 400 == 0:
# divisible by 4 and 100 and 400
print("yes")
else:
# divisible by 4 and 100 not 400
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...positive integer that represents a year...
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400.
year = int(reader.readline())
if year <= 0:
print("Error")
else:
if year % 4 == 0:
# divisible by 4
if year % 100 == 0:
# divisible by 4 and 100
if year % 400 == 0:
# divisible by 4 and 100 and 400
print("yes")
else:
# divisible by 4 and 100 not 400
print("no")
else:
# divisible by 4 but not 100
print("yes")
else:
# not divisible by 4
print("no")
...positive integer that represents a year...
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400.