diff --git a/problems/easy/easy_q3.py b/problems/easy/easy_q3.py index 10d2862..f89a02b 100644 --- a/problems/easy/easy_q3.py +++ b/problems/easy/easy_q3.py @@ -1,20 +1,12 @@ -# Leap Year or Not: Write a program to determine whether a given year is a leap year. def is_leap_year(year): - - if year % 4 == 0: - print("leap year") + if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0): + print(f"{year} is a leap year") else: - print("not a leap year") + print(f"{year} is not a leap year") if __name__ == "__main__": - - num = int(input("Enter the number :")) - is_leap_year(num) - - if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: - - return "Leap Year" - else: - - return "Not a Leap Year" - \ No newline at end of file + try: + num = int(input("Enter the year: ")) + is_leap_year(num) + except ValueError: + print("Please enter a valid integer year.") diff --git a/problems/easy/easy_q5.py b/problems/easy/easy_q5.py index 2c4d166..7b3225f 100644 --- a/problems/easy/easy_q5.py +++ b/problems/easy/easy_q5.py @@ -1,22 +1,10 @@ -def grade_system(marks): - - if marks >= 90: - return "A" - elif marks >= 80: - return "B" - elif marks >= 70: - - return "c" - else: - return "F" - -if __name__ == "__main__": - num = int(input("Enter the Mark : ")) - res = grade_system(num) - print(res) - - return "C" - else: - return "F" +def grade_system(m): + if m >= 90: return "A" + elif m >= 80: return "B" + elif m >= 70: return "C" + else: return "F" +marks = int(input("Enter Marks: ")) +print(grade_system(marks)) + \ No newline at end of file