-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_17.py
More file actions
31 lines (21 loc) · 754 Bytes
/
3_17.py
File metadata and controls
31 lines (21 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
17. A year is a leap year if it is divisible by 4, except that years divisible by 100 are not leap years
unless they are also divisible by 400. Ask the user to enter a year, and, using the // operator,
determine how many leap years there have been between 1600 and that year.
"""
end = eval(input('Enter the final year:'))
ly= 0
for year in range(1600,(end + 1)):
if(year%4 == 0):
if(year%100 == 0):
if(year%400 == 0):
print(year,'is leap year')
ly = ly + 1
else:
print(year,'not a leap year')
else:
print(year,'is a leap year')
ly = ly + 1
else:
print(year,'not a leap year')
print('Total:',ly)