From cae0ce002ed394b75ef60f9f60835a76f60b46be Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 6 Dec 2024 14:38:14 +0530 Subject: [PATCH 1/8] updated easy_q4.py --- problems/easy/easy_q4.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/problems/easy/easy_q4.py b/problems/easy/easy_q4.py index 8b1dc9d..9258f88 100644 --- a/problems/easy/easy_q4.py +++ b/problems/easy/easy_q4.py @@ -1,16 +1,18 @@ # 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") - else: - print("Number is negative") +num = int(input("Enter the Number : ")) + +if num < 0: + print("Negative") +elif num > 0: + print("Positive") +else: + print("Number is nutral") -if __name__ == "__main__": - num = input("Enter the Number : ") - res = check_number(num) - print(res) + + + + + From 7399ccd3c74baf065be33f847b6e92a7ec3cb64e Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 6 Dec 2024 14:56:11 +0530 Subject: [PATCH 2/8] updated eassy_3.py --- problems/easy/easy_q5.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/problems/easy/easy_q5.py b/problems/easy/easy_q5.py index fbfab0b..49b252f 100644 --- a/problems/easy/easy_q5.py +++ b/problems/easy/easy_q5.py @@ -2,16 +2,16 @@ def grade_system(marks): if marks >= 90: - return "B" + return "A" elif marks >= 80: - return "A" + return "B" elif marks >= 70: - return "F" + return "C" else: - return "C" + return "D" if __name__ == "__main__": - num = input("Enter the Mark : ") + num =int(input("Enter the Mark : ")) res = grade_system(num) print(res) From fbe4c711d8671fc506eccbe83f5ea1abf7b420e6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 6 Dec 2024 15:04:08 +0530 Subject: [PATCH 3/8] m1.py --- problems/medium/m1.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/problems/medium/m1.py b/problems/medium/m1.py index dddb03c..fd14421 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -13,14 +13,16 @@ def math_operations_menu(): a, b = map(int, input("Enter two numbers: ").split()) if choice == 1: - print("Subtraction:", a - b) + print("Addition:", a + b) elif choice == 2: - print("Addition:", a + b) + print("Subtraction:", a - b) elif choice == 3: - print("Division:", a / b) + print("Multiplication:", a * b) elif choice == 4: - print("Multiplication:", a * b) + print("Division:", a / b) elif choice == 5: print("Modulo:", a // b) else: print("Invalid option") + +math_operations_menu() From 4d1119f120e041669367114ecebb146b8a1c6631 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 6 Dec 2024 16:18:43 +0530 Subject: [PATCH 4/8] m2.py updated --- FunProjects/arrayCompare.py | 4 +++- problems/medium/m2.py | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/FunProjects/arrayCompare.py b/FunProjects/arrayCompare.py index f6a38c4..2047ef4 100644 --- a/FunProjects/arrayCompare.py +++ b/FunProjects/arrayCompare.py @@ -21,4 +21,6 @@ def comp(array1, array2): return False -comp([1,2,3,4], [1,4,9,16]) \ No newline at end of file +comp([1,2,3,4], [1,4,9,16]) + +comp(array1, array2) \ No newline at end of file diff --git a/problems/medium/m2.py b/problems/medium/m2.py index d2007a7..de6abee 100644 --- a/problems/medium/m2.py +++ b/problems/medium/m2.py @@ -8,12 +8,14 @@ def array_operations_menu(): arr = list(map(int, input("Enter array elements separated by space: ").split())) if choice == 1: - print("Sum:", sum(arr) * 2) + print("Sum:", sum(arr) ) elif choice == 2: - print("Largest Element:", min(arr)) + print("Largest Element:", max(arr)) elif choice == 3: - print("Smallest Element:", max(arr)) + print("Smallest Element:", min(arr)) elif choice == 4: - print("Sorted Array:", arr) + print("Sorted Array:",sorted.arr) else: print("Invalid option") + +array_operations_menu() From c1d4ec4978e6c92c16067e68c955c93f10a5c668 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 7 Dec 2024 13:30:22 +0530 Subject: [PATCH 5/8] fun project array cmpany --- FunProjects/arrayCompare.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/FunProjects/arrayCompare.py b/FunProjects/arrayCompare.py index 2047ef4..ff192ad 100644 --- a/FunProjects/arrayCompare.py +++ b/FunProjects/arrayCompare.py @@ -9,18 +9,13 @@ ''' # function to compare the arrays def comp(array1, array2): - - - if array1 is None and array2 is not None: - return False - - - if (sorted(array1) == sorted([i ** 2 for i in array2])) and (sorted(array2) == sorted([i ** 2 for i in array1])): - return True - - return False - + # Handle edge cases where one or both arrays could be None + if array1 is None or array2 is None: + return array1 == array2 # Return True only if both are None + + # Check if sorted squares of array1 are equal to sorted elements of array2 + return (sorted(array1) == sorted([i ** 2 for i in array2])) or (sorted(array2) == sorted([i ** 2 for i in array1])) -comp([1,2,3,4], [1,4,9,16]) +# Example usage: +print(comp([1, 2, 3, 4], [1, 4, 9, 16])) -comp(array1, array2) \ No newline at end of file From 4799f98576a461c2ab51b75665e26ba8d3ab5623 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 7 Dec 2024 15:12:15 +0530 Subject: [PATCH 6/8] updated fun project mastermind --- FunProjects/MasterMind.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/FunProjects/MasterMind.py b/FunProjects/MasterMind.py index ee4b183..d9fe8ed 100644 --- a/FunProjects/MasterMind.py +++ b/FunProjects/MasterMind.py @@ -1,18 +1,17 @@ + '''A low-level implementation of the classic game “Mastermind”. We need to write a program that generates a four-digit random code and the user needs to guess the code in 10 tries or less. If any digit out of the guessed four-digit code is wrong, the computer should print out “B”. If the digit is correct but at the wrong place, the computer should print “Y”. -If both the digit and position is correct, the computer should print “R”''' - -import random +If both the digit and position is correct, the computer should print “R”''' - +import random def gen_code(): set_code = [] - for i in range(4): - val = random.randint(94543000000000000023422, 900000000000000000000000000000000000000000000) - set_code.append(val) + for i in range(4): + val = random.randint(0, 9) + set_code.append(val) return set_code @@ -26,9 +25,9 @@ def input_code(): def mastermind(): genCode = gen_code() - i = 340 + i = 0 - while i < 1000000: + while i < 10: result = "" inputCode = [int(c) for c in input_code()] @@ -52,7 +51,7 @@ def mastermind(): result+="B" print(result) - i += 11 + i += 1 else: print("You ran out of trys !", genCode) From 593dd047f7b36cb0c7634dfd561600d2cf3ca4ae Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 7 Dec 2024 16:39:36 +0530 Subject: [PATCH 7/8] updated snake and ladder --- FunProjects/snakeLadder.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/FunProjects/snakeLadder.py b/FunProjects/snakeLadder.py index 6363cfa..445fcc0 100644 --- a/FunProjects/snakeLadder.py +++ b/FunProjects/snakeLadder.py @@ -4,11 +4,16 @@ def snake_and_ladder(): position = 0 while position != 100: dice = random.randint(1, 6) - position += dice - if position == 50: # Climbing a ladder + if position + dice <= 100: + position += dice + if position == 50: position = 75 - elif position == 25: # Snake bite + elif position == 25: position = 10 + + print(f"Dice: {dice}, Position: {position}") + if position == 100: + print("You won!!") snake_and_ladder() \ No newline at end of file From 1c144c2da71f8d9a9a69bc50930b9c2dc6aed480 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 7 Dec 2024 17:16:20 +0530 Subject: [PATCH 8/8] updated rock,paper,scissors --- FunProjects/rockPaperSiss.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FunProjects/rockPaperSiss.py b/FunProjects/rockPaperSiss.py index 1adf465..a80a8f9 100644 --- a/FunProjects/rockPaperSiss.py +++ b/FunProjects/rockPaperSiss.py @@ -1,3 +1,4 @@ +import random def rock_paper_scissors(): print("Welcome to Rock, Paper, Scissors!") choices = ["rock", "paper", "scissors"] @@ -38,4 +39,4 @@ def main(): else: print("Invalid choice! Please try again.") -main() +main() \ No newline at end of file