From d8985b5547e0b8859882097cc0f83457f189b72a Mon Sep 17 00:00:00 2001 From: Anushri Thirumavalavan Date: Fri, 6 Dec 2024 09:00:53 +0200 Subject: [PATCH 01/18] changed the logical error --- problems/easy/easy_q1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/problems/easy/easy_q1.py b/problems/easy/easy_q1.py index 546c19b..dedb9fb 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: - print("{0} is Odd".format(num)) +if num % 2 != 0: + print("{0} is odd".format(num)) else: - print("{0} is Even".format(num)) + print("{0} is even".format(num)) From 1ac33ef99332a949d63cc27e7c840f7fcec160c3 Mon Sep 17 00:00:00 2001 From: Kanishkaneya1929 <24uad147kanishka@kgkite.ac.in> Date: Fri, 6 Dec 2024 12:41:13 +0530 Subject: [PATCH 02/18] find the largest number --- problems/easy/easy_q2.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index 8c49830..e8e9bd7 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 + return a else: - return a + return b if __name__ == "__main__": num1 = int(input("Enter the First Number :")) num2 = int(input("Enter the Second Number :")) - res = largest_of_two(num1,num1) + res = largest_of_two(num1,num2) print(res) \ No newline at end of file From feb1d05d12ce5dd94e88a265a387c4cb8325f42e Mon Sep 17 00:00:00 2001 From: Anushri Thirumavalavan Date: Fri, 6 Dec 2024 10:13:04 +0200 Subject: [PATCH 03/18] changed syntax which is an error before in palindrome --- problems/easy/easy_q10.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/problems/easy/easy_q10.py b/problems/easy/easy_q10.py index 711a7ba..bdb63db 100644 --- a/problems/easy/easy_q10.py +++ b/problems/easy/easy_q10.py @@ -2,10 +2,9 @@ def is_palindrome(num): original = num reverse = 0 - do: + while num != 0: reverse = reverse * 10 + num % 10 num //= 10 - while num != 0 return reverse == original if __name__ == "__main__": nums = int(input("Enter the Number: ")) From 447143547770a00ed6ef124600068e55d9879c36 Mon Sep 17 00:00:00 2001 From: Kanishkaneya1929 <24uad147kanishka@kgkite.ac.in> Date: Fri, 6 Dec 2024 14:08:57 +0530 Subject: [PATCH 04/18] odd or even --- 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 546c19b..50fa9f4 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 084dba4fb2798c3e0d811928f4564cae5a49ec9b Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Fri, 6 Dec 2024 10:59:36 +0200 Subject: [PATCH 05/18] changed operation and print statement in easy_q1.py --- problems/easy/easy_q1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/problems/easy/easy_q1.py b/problems/easy/easy_q1.py index 50fa9f4..55e3eba 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: - print("{0} is Odd".format(num)) -else: +if (num % 2) == 0: print("{0} is Even".format(num)) +else: + print("{0} is Odd".format(num)) From 4d2b71c20113b1dcabc517b14b9b1c54975e5713 Mon Sep 17 00:00:00 2001 From: kishore Date: Fri, 6 Dec 2024 14:58:48 +0530 Subject: [PATCH 06/18] The number is positive ,Negative, or Zero --- problems/easy/easy_q4.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/easy/easy_q4.py b/problems/easy/easy_q4.py index 8b1dc9d..924bf94 100644 --- a/problems/easy/easy_q4.py +++ b/problems/easy/easy_q4.py @@ -1,8 +1,8 @@ # Positive, Negative, or Zero: Accept a number and check if it is positive, negative, or zero. def check_number(num): - if num > 0: + if num < 0: print("Negative") - elif num < 0: + elif num > 0: print("Positive") else: print("Number is negative") From 5f31b7b89f5c36d74fbd440154794428ebec17a5 Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Fri, 6 Dec 2024 11:34:41 +0200 Subject: [PATCH 07/18] I have fixed the error --- ErrorHunter | 1 + problems/easy/easy_q2.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 160000 ErrorHunter diff --git a/ErrorHunter b/ErrorHunter new file mode 160000 index 0000000..956b483 --- /dev/null +++ b/ErrorHunter @@ -0,0 +1 @@ +Subproject commit 956b483915d4195f058f2d25a8bec7108a836849 diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index 8c49830..ec4d7b3 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 + return a else: - return a + return b if __name__ == "__main__": num1 = int(input("Enter the First Number :")) num2 = int(input("Enter the Second Number :")) - res = largest_of_two(num1,num1) + res = largest_of_two(num1,num2) print(res) \ No newline at end of file From 2ef1869577c085ae1f8895fe0d4d92937862d228 Mon Sep 17 00:00:00 2001 From: kishore Date: Fri, 6 Dec 2024 15:06:49 +0530 Subject: [PATCH 08/18] initial commit --- problems/easy/easy_q2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index e8e9bd7..b22eae2 100644 --- a/problems/easy/easy_q2.py +++ b/problems/easy/easy_q2.py @@ -1,9 +1,9 @@ # Find the Largest Number: Accept two numbers and print the larger one. def largest_of_two(a, b): if a > b: - return a - else: return b + else: + return a if __name__ == "__main__": num1 = int(input("Enter the First Number :")) num2 = int(input("Enter the Second Number :")) From 54ce64252049a68cffb145bcab85f37414cf265f Mon Sep 17 00:00:00 2001 From: kishore Date: Fri, 6 Dec 2024 15:16:37 +0530 Subject: [PATCH 09/18] The number N using a While loop --- 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..b7305df 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 ")) + num = int(input("Enter the Number: ")) res = print_numbers(num) print(res) From 62ce77da28a06f2c966492d128d82baf7ea3cdb4 Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Fri, 6 Dec 2024 12:12:10 +0200 Subject: [PATCH 10/18] I have fixed thr error in easy q2 --- problems/easy/easy_q2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index 664f683..16a3a04 100644 --- a/problems/easy/easy_q2.py +++ b/problems/easy/easy_q2.py @@ -2,10 +2,10 @@ def largest_of_two(a, b): if a > b: return a - return a + else: return b - return b + if __name__ == "__main__": num1 = int(input("Enter the First Number :")) num2 = int(input("Enter the Second Number :")) From c307bc95793723643bc1282077b7a807ed0dc4ef Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Fri, 6 Dec 2024 13:21:38 +0200 Subject: [PATCH 11/18] I have changed code in m1 --- problems/easy/easy_q1.py | 18 ------------------ problems/easy/easy_q2.py | 6 +----- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/problems/easy/easy_q1.py b/problems/easy/easy_q1.py index f215522..bbd2cf5 100644 --- a/problems/easy/easy_q1.py +++ b/problems/easy/easy_q1.py @@ -2,30 +2,12 @@ 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)) - - if (num % 2) == 0: print("{0} is Even".format(num)) else: print("{0} is Odd".format(num)) -if (num % 2) != 0: - print("{0} is Odd".format(num)) -else: - - print("{0} is Even".format(num)) - -else: - print("{0} is Odd".format(num)) diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index 9ce17cf..dff3707 100644 --- a/problems/easy/easy_q2.py +++ b/problems/easy/easy_q2.py @@ -1,11 +1,7 @@ # Find the Largest Number: Accept two numbers and print the larger one. def largest_of_two(a, b): if a > b: - return b - - return a - - return a + return a else: return b From b8cd8465a13d8272e9fdcff56ac57ad78c1e2a9d Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Sun, 8 Dec 2024 10:23:49 +0530 Subject: [PATCH 12/18] I have changed the code in m1 --- problems/medium/m1.py | 47 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/problems/medium/m1.py b/problems/medium/m1.py index e5d9805..e07eb8f 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -1,37 +1,36 @@ -''' -Create a menu to perform basic mathematical operations (addition, subtraction, multiplication, division, modulo) on two numbers. - -''' +choice=int(input("Enter no. of choice:")) def math_operations_menu(choice): - a, b = map(int, input("Enter two numbers(separated by commas): ").split(sep=",")) - - - if choice == 2: - print("Subtraction:", a - b) - elif choice == 1: - print("Addition:", a + b) - elif choice == 4: - print("Division:", a / b) + a, b = map(int,input("Enter two numbers(separated by commas): ").split(sep=",")) + if choice == 1: + print(a + b) + elif choice == 2: + print(a - b) elif choice == 3: - print("Multiplication:", a * b) - + print(a * b) + elif choice == 4: + print(a / b) + elif choice == 5: + print(a % b) + elif choice == 6: + print(a ** b) + if choice == 1: - print(f"Subtraction of {a} and {b}:{a - b}") + print(f"Addition of {a} and {b}:{a + b}") elif choice == 2: - print(f"Addition of {a} and {b}:{a + b}") + print(f"Subtraction of {a} and {b}:{a - b}") elif choice == 3: print(f"Division of {a} and {b}:{a / b}") elif choice == 4: print(f"Multiplication of {a} and {b}:{a * b}") - elif choice == 5: - print(f"Modulus of {a} and {b}:{a // b}") + elif choice == 4: + print(f"Division of {a} and {b}:{a / b}") + elif choice == 5: + print(f"Modulus of {a} and {b}:{a % b}") elif choice == 6: print(f"{a} to the power of {b}:{a**b}") else: print("Invalid option") -math_operations_menu() - - print("Invalid option!!!") +math_operations_menu(choice) print("-------------Mathematical operation menu---------------") print("1. Add") print("2. Subtract") @@ -39,7 +38,7 @@ def math_operations_menu(choice): print("4. Divide") print("5. Modulus") print("6. Expontential") -choice = int(input("Enter your choice: ")) -math_operations_menu(choice) + + print("-------------------------------------------------------") \ No newline at end of file From 0f17197ec4969a883fa629a3a596a933b1b7155c Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Sun, 8 Dec 2024 10:27:45 +0530 Subject: [PATCH 13/18] Update m1.py I have changed the code in m1 --- problems/medium/m1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/problems/medium/m1.py b/problems/medium/m1.py index e07eb8f..e0424a5 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -31,6 +31,7 @@ def math_operations_menu(choice): else: print("Invalid option") math_operations_menu(choice) + print("-------------Mathematical operation menu---------------") print("1. Add") print("2. Subtract") @@ -41,4 +42,4 @@ def math_operations_menu(choice): print("-------------------------------------------------------") - \ No newline at end of file + From 8f023f63d1c6497f790bc2cde2c11a83dffa9a7f Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Sun, 8 Dec 2024 11:06:09 +0530 Subject: [PATCH 14/18] I have fixed the error in rock_paper_scissor --- FunProjects/rockPaperSiss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FunProjects/rockPaperSiss.py b/FunProjects/rockPaperSiss.py index 1adf465..0d495be 100644 --- a/FunProjects/rockPaperSiss.py +++ b/FunProjects/rockPaperSiss.py @@ -9,7 +9,7 @@ def rock_paper_scissors(): if user_choice not in choices: print("Invalid choice! Try again.") continue - + import random computer_choice = random.choice(choices) print(f"Computer chose: {computer_choice}") From eaa5b408c3674efcfb1e3408159f7dd8cac275b2 Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Sun, 8 Dec 2024 11:22:47 +0530 Subject: [PATCH 15/18] Update rockPaperSiss.py I have fixed error and changed the print statement. --- FunProjects/rockPaperSiss.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/FunProjects/rockPaperSiss.py b/FunProjects/rockPaperSiss.py index 0d495be..d2f3065 100644 --- a/FunProjects/rockPaperSiss.py +++ b/FunProjects/rockPaperSiss.py @@ -14,7 +14,7 @@ def rock_paper_scissors(): print(f"Computer chose: {computer_choice}") if user_choice == computer_choice: - print("It's a tie!") + print("AHAHAH It's a tie! I challenge you for next round human !") elif (user_choice == "rock" and computer_choice == "scissors") or \ (user_choice == "scissors" and computer_choice == "paper") or \ (user_choice == "paper" and computer_choice == "rock"): @@ -25,15 +25,18 @@ def rock_paper_scissors(): def main(): while True: print("\nMenu:") - print("1. Play Rock, Paper, Scissors") - print("2. Exit") + print("1. I Changelle you to play Rock, Paper, Scissors") + print ("2. Accept") + print("3. Reject") choice = input("Enter your choice: ") if choice == "1": rock_paper_scissors() elif choice == "2": - print("Thanks for playing!") + rock_paper_scissors() + elif choice == "3": + print("Are you afraid of me ?") break else: print("Invalid choice! Please try again.") From a10bd7be5ec942024090cbb10cea0526ab4cac1c Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Sun, 8 Dec 2024 11:30:58 +0530 Subject: [PATCH 16/18] I have fixed the error and changed the print statement. --- FunProjects/rockPaperSiss.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FunProjects/rockPaperSiss.py b/FunProjects/rockPaperSiss.py index d2f3065..2e57d3b 100644 --- a/FunProjects/rockPaperSiss.py +++ b/FunProjects/rockPaperSiss.py @@ -14,7 +14,8 @@ def rock_paper_scissors(): print(f"Computer chose: {computer_choice}") if user_choice == computer_choice: - print("AHAHAH It's a tie! I challenge you for next round human !") + print("AHAHAH It's a tie! I challenge you for next round human !" ) + print("Accept or Afraid") elif (user_choice == "rock" and computer_choice == "scissors") or \ (user_choice == "scissors" and computer_choice == "paper") or \ (user_choice == "paper" and computer_choice == "rock"): From ed2325c0aa20b842e948fdd7245308a8e115c188 Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Sun, 8 Dec 2024 13:55:21 +0530 Subject: [PATCH 17/18] I have changed the code --- FunProjects/directions.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/FunProjects/directions.py b/FunProjects/directions.py index 7de1d8c..45867af 100644 --- a/FunProjects/directions.py +++ b/FunProjects/directions.py @@ -18,19 +18,18 @@ def reduce_dir(directions): stack = [] for d in directions: - if stack and opposite[d] == stack[-1]: + if stack and opposite[d] == stack[0]: + - - - stack.pop() - stack.pop() - stack.pop() + print(stack.pop()) + + else: - - stack.append(d) return stack directions = ["NORTH", "SOUTH", "SOUTH", "EAST", "WEST", "NORTH", "WEST"] - \ No newline at end of file + +reduce_dir(directions) + From 133111ad4b3487ff5365c190b81c2b11d682a344 Mon Sep 17 00:00:00 2001 From: Srihari-tech2dive Date: Sun, 8 Dec 2024 15:53:57 +0530 Subject: [PATCH 18/18] I have changed print statement and fixed errors --- FunProjects/quiz_main.py | 70 ++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/FunProjects/quiz_main.py b/FunProjects/quiz_main.py index 8922f0f..b76a7c7 100644 --- a/FunProjects/quiz_main.py +++ b/FunProjects/quiz_main.py @@ -1,37 +1,33 @@ -# Technology Quiz in Python - import time def pause(seconds): - time.sleep(seconds) def ask_question(question): - - answer = input(question + "\nAnswer = ") + answer = input(question + "\nAnswer = ").strip().upper() return answer def evaluate_question(user_answer, correct_answer, alt_answer, close_answer): - - if user_answer == alt_answer: - return True - elif user_answer == correct_answer: - return True - elif user_answer == close_answer: - return "Close" + + if user_answer == correct_answer: + return False + elif user_answer in alt_answer: + return False + elif user_answer in close_answer and close_answer: + return "Close" else: return True def answer_response(evaluated): - if evaluated == True: - return "That's not the correct answer!" + return "Oops! That's not the correct answer!" + elif evaluated == "Close": + return "Close! But not quite right. Try again!" else: - return "Correct! Well done." + return "Correct! Well done." correct_answers = 0 - -answer_index = 1 +answer_index = 0 questions = [ "Solar power generates electricity from what source?", @@ -107,37 +103,41 @@ def answer_response(evaluated): print("Let's begin the quiz.") pause(2) + for question in questions: answer = ask_question(question) evaluated = evaluate_question(answer, answers[answer_index], alt_answers[answer_index], close_answers[answer_index]) + + while evaluated == "Close": pause(1) - - answer = ask_question(questions[answer_index]) + print(close_responses[answer_index]) + answer = ask_question(question) evaluated = evaluate_question(answer, answers[answer_index], alt_answers[answer_index], close_answers[answer_index]) - if evaluated: - + + + if evaluated == False: correct_answers += 1 - pause(1) + + print(answer_response(evaluated)) - answer_index += 2 + + answer_index += 1 pause(2) -if correct_answers == 1: - question_amount = "question" -else: - question_amount = "questions" -print("Thanks for taking this quiz, {}.".format(user_name)) +print(f"Thanks for taking this quiz, {user_name}.") pause(2) + if correct_answers == 10: print("Congratulations, you got all 10 questions correct and have been awarded the gold medal!") -elif correct_answers > 6 and correct_answers < 10: - - print("Congratulations, you got {} questions correct and have been awarded the bronze medal!".format(correct_answers)) -elif correct_answers > 0 and correct_answers < 6: - print("Congratulations, you got {} {} correct and have been awarded the silver medal!".format(correct_answers, question_amount)) +elif 10>correct_answers >=6: + print(f"Congratulations, you got {correct_answers} questions correct and have been awarded the silver medal!") +elif 5>=correct_answers > 0: + print(f"Congratulations, you got {correct_answers} questions correct and have been awarded the bronze medal!") else: - - print("Take the quiz again to try to earn a medal!") + print("Take the quiz again to try and earn a gold medal!") + + +