From 57d158923c822fae2e27d6046e7dad7fe2caa9e9 Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 12:15:05 +0530 Subject: [PATCH 1/9] solved one issue --- problems/easy/easy_q1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/easy/easy_q1.py b/problems/easy/easy_q1.py index 50fa9f4..2fd320a 100644 --- a/problems/easy/easy_q1.py +++ b/problems/easy/easy_q1.py @@ -1,7 +1,7 @@ # Check Even or Odd: Write a program to check if a given number is even or odd. num = int(input("Enter a number: ")) -if (num % 2) != 0: +if (num % 2) != 0: print("{0} is Odd".format(num)) else: print("{0} is Even".format(num)) From 3459897f4ca3dae05a5936ba3c3478a4ce97976a Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 12:32:32 +0530 Subject: [PATCH 2/9] debugged_q2 --- problems/easy/easy_q2.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index 8c49830..404f6b3 100644 --- a/problems/easy/easy_q2.py +++ b/problems/easy/easy_q2.py @@ -1,11 +1,11 @@ # Find the Largest Number: Accept two numbers and print the larger one. def largest_of_two(a, b): if a > b: - return b - else: - return a -if __name__ == "__main__": - num1 = int(input("Enter the First Number :")) - num2 = int(input("Enter the Second Number :")) - res = largest_of_two(num1,num1) - print(res) \ No newline at end of file + print(a) + else: + print(b) + +#if __name__ == "__main__": +num1 = int(input("Enter the First Number :")) +num2 = int(input("Enter the Second Number :")) +largest_of_two(num1,num2) \ No newline at end of file From 6d0f8ecdbcec647cb294bb6c8bd1d1d9d8c547cb Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 12:34:33 +0530 Subject: [PATCH 3/9] debugged_q2 --- problems/easy/easy_q2.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index 404f6b3..8effa89 100644 --- a/problems/easy/easy_q2.py +++ b/problems/easy/easy_q2.py @@ -5,7 +5,7 @@ def largest_of_two(a, b): else: print(b) -#if __name__ == "__main__": -num1 = int(input("Enter the First Number :")) -num2 = int(input("Enter the Second Number :")) -largest_of_two(num1,num2) \ No newline at end of file +if __name__ == "__main__": + num1 = int(input("Enter the First Number :")) + num2 = int(input("Enter the Second Number :")) + largest_of_two(num1,num2) \ No newline at end of file From fbe3f0635b252a964b180e08d79c546a2e343ddb Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 12:43:57 +0530 Subject: [PATCH 4/9] debugged_q3 --- problems/easy/easy_q3.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/problems/easy/easy_q3.py b/problems/easy/easy_q3.py index 8df3340..ab99555 100644 --- a/problems/easy/easy_q3.py +++ b/problems/easy/easy_q3.py @@ -1,8 +1,9 @@ # 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 and year % 100 != 0 or year % 400 == 0: - return "Not a Leap Year" - return "Leap Year" + if year % 400 == 0 and year % 100 == 0 or year % 4 == 0: + return "Leap Year" + else: + return "Not a Leap Year" if __name__ == "__main__": num = int(input("Enter the number :")) From 547e07600723a28f55fad39ff2e7da6eed239204 Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 13:46:08 +0530 Subject: [PATCH 5/9] debugged_q5 --- problems/easy/easy_q5.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/problems/easy/easy_q5.py b/problems/easy/easy_q5.py index fbfab0b..06f5b5d 100644 --- a/problems/easy/easy_q5.py +++ b/problems/easy/easy_q5.py @@ -1,17 +1,19 @@ # Grading System: Write a program that takes a student’s marks as input and prints the grade (A, B, C, or F) based on given thresholds. def grade_system(marks): - if marks >= 90: - return "B" - elif marks >= 80: - return "A" - elif marks >= 70: - return "F" - else: + if marks < 100 and marks >= 90: + return "A" + elif marks < 90 and marks >= 80: + return "B" + elif marks <80 and marks >= 70: return "C" + elif marks < 0 or marks > 100: + return "Invalid marks" + else: + return "F" if __name__ == "__main__": - num = input("Enter the Mark : ") + num = int(input("Enter the Mark : ")) res = grade_system(num) print(res) From bd6c7a181adffc79568aa32890c52194b846c715 Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 13:52:54 +0530 Subject: [PATCH 6/9] debugged_q6 --- problems/easy/easy_q6.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/problems/easy/easy_q6.py b/problems/easy/easy_q6.py index 3ac65c7..7b3cef9 100644 --- a/problems/easy/easy_q6.py +++ b/problems/easy/easy_q6.py @@ -3,9 +3,8 @@ def print_numbers(n): i = 1 while i <= n: print(i) - n -= 1 + i += 1 if __name__ == "__main__": num = int(input("Enter the Number ")) - res = print_numbers(num) - print(res) + print_numbers(num) \ No newline at end of file From cf31d8a9228f37701cf0eeb1625eda80c5a44962 Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 14:03:56 +0530 Subject: [PATCH 7/9] debugged_q4 --- problems/easy/easy_q4.py | 11 +++++------ problems/easy/easy_q7.py | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/problems/easy/easy_q4.py b/problems/easy/easy_q4.py index 8b1dc9d..c4e3ab8 100644 --- a/problems/easy/easy_q4.py +++ b/problems/easy/easy_q4.py @@ -1,16 +1,15 @@ # Positive, Negative, or Zero: Accept a number and check if it is positive, negative, or zero. def check_number(num): if num > 0: - print("Negative") - elif num < 0: print("Positive") + elif num < 0: + print("Negative") else: - print("Number is negative") + print("Number is zero") if __name__ == "__main__": - num = input("Enter the Number : ") - res = check_number(num) - print(res) + num = int(input("Enter the Number : ")) + check_number(num) diff --git a/problems/easy/easy_q7.py b/problems/easy/easy_q7.py index 8efa72e..283f5d5 100644 --- a/problems/easy/easy_q7.py +++ b/problems/easy/easy_q7.py @@ -2,11 +2,12 @@ def sum_of_digits(num): total = 0 while num > 0: - total += num % 10 - num = num + 10 - return total + total += num + num += 1 + print(total) if __name__ == "__main__": num = int(input("Enter the Number : ")) + sum_of_digits(num) From 3b999fba3c7a3c0fdea267bed01d63c133a141f6 Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 14:21:44 +0530 Subject: [PATCH 8/9] debugged_q7 --- problems/easy/easy_q7.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/easy/easy_q7.py b/problems/easy/easy_q7.py index 283f5d5..5b3097e 100644 --- a/problems/easy/easy_q7.py +++ b/problems/easy/easy_q7.py @@ -2,8 +2,8 @@ def sum_of_digits(num): total = 0 while num > 0: - total += num - num += 1 + total += num % 10 + num //= 10 print(total) if __name__ == "__main__": From c094439c05879a7d31f7d67ba310b8cc0e6679f6 Mon Sep 17 00:00:00 2001 From: Mirdula18 Date: Fri, 6 Dec 2024 14:34:21 +0530 Subject: [PATCH 9/9] debugged_m1 --- problems/medium/m1.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/problems/medium/m1.py b/problems/medium/m1.py index dddb03c..95a8035 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -2,25 +2,26 @@ Create a menu to perform basic mathematical operations (addition, subtraction, multiplication, division, modulo) on two numbers. ''' -def math_operations_menu(): - print("1. Add") - print("2. Subtract") - print("3. Multiply") - print("4. Divide") - print("5. Modulo") - choice = int(input("Enter your choice: ")) - - a, b = map(int, input("Enter two numbers: ").split()) +def math_operations_menu(choice): + a, b = map(int, input("Enter two numbers: ").split(sep=",")) if choice == 1: print("Subtraction:", a - b) elif choice == 2: print("Addition:", a + b) elif choice == 3: - print("Division:", a / b) - elif choice == 4: print("Multiplication:", a * b) + elif choice == 4: + print("Division:", a / b) elif choice == 5: - print("Modulo:", a // b) + print("Modulo:", a % b) else: print("Invalid option") + +print("1. Add") +print("2. Subtract") +print("3. Multiply") +print("4. Divide") +print("5. Modulo") +choice = int(input("Enter your choice: ")) +math_operations_menu(choice)