Skip to content

Commit 563fc23

Browse files
committed
check leap year
1 parent e354302 commit 563fc23

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Programs/AddTwoNumbers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# print("Sum of given two numbers :", num1 + num2)
66

77
# ============= Solution 02 =============
8+
print("Welcome to TowSome programme")
89
num1 = float(input("Enter first number :"))
910
num2 = float(input("Enter second number :"))
1011
print("Sum of given two numbers :", num1 + num2)

Programs/CheckLeapYear.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
print("Welcome to Leap Year programme!")
2+
3+
def check_leap_year(y):
4+
if ((y % 4 == 0) and (y % 100 != 0)) or (y % 400 == 0):
5+
print(str(y) + " is a leap year !")
6+
retry = input("Do you want to retry? (y/q): ").lower()
7+
if retry != "y":
8+
quit()
9+
else:
10+
print(str(y) + " is not a leap year")
11+
retry = input("Do you want to retry? (y/q): ").lower()
12+
if retry != "y":
13+
quit()
14+
15+
while True:
16+
y = input("Enter year : ")
17+
if y.isnumeric():
18+
y = int(y)
19+
check_leap_year(y)
20+
else:
21+
print("Not a valid input")
22+
retry = input("Do you want to retry? (y/q): ").lower()
23+
if retry != "y":
24+
break

0 commit comments

Comments
 (0)