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/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) + 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!") + + + diff --git a/FunProjects/rockPaperSiss.py b/FunProjects/rockPaperSiss.py index 1adf465..2e57d3b 100644 --- a/FunProjects/rockPaperSiss.py +++ b/FunProjects/rockPaperSiss.py @@ -9,12 +9,13 @@ 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}") if user_choice == computer_choice: - print("It's a tie!") + 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"): @@ -25,15 +26,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.") diff --git a/problems/easy/easy_q1.py b/problems/easy/easy_q1.py index 759376b..bbd2cf5 100644 --- a/problems/easy/easy_q1.py +++ b/problems/easy/easy_q1.py @@ -7,10 +7,8 @@ else: print("{0} is Odd".format(num)) -if (num % 2) != 0: - print("{0} is Odd".format(num)) -else: - print("{0} is Even".format(num)) + + diff --git a/problems/easy/easy_q10.py b/problems/easy/easy_q10.py index 3ad440b..84254b5 100644 --- a/problems/easy/easy_q10.py +++ b/problems/easy/easy_q10.py @@ -6,7 +6,10 @@ def is_palindrome(num): while num != 0: reverse = reverse * 10 + num % 10 num //= 10 + + + return reverse == original reverse = '' diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index 110f086..dff3707 100644 --- a/problems/easy/easy_q2.py +++ b/problems/easy/easy_q2.py @@ -1,43 +1,24 @@ # Find the Largest Number: Accept two numbers and print the larger one. def largest_of_two(a, b): if a > b: - - return a + return a + else: return b + if __name__ == "__main__": num1 = int(input("Enter the First Number :")) num2 = int(input("Enter the Second Number :")) res = largest_of_two(num1,num2) - print(res) - print(num1,"larger") - else: - print(num2,"larger") - -if __name__ == "__main__": - num1 = int(input("Enter the First Number :")) - num2 = int(input("Enter the Second :")) - res = largest_of_two(num1,num1) - print(res) - - - return a + res = largest_of_two(num1,num2) - return a - else: - return b -if __name__ == "__main__": - num1 = int(input("Enter the First Number :")) - num2 = int(input("Enter the Second Number :")) - res = largest_of_two(num1,num2) - keerthi print("The Largest Number is",res) + print(res) - - - main + + diff --git a/problems/easy/easy_q6.py b/problems/easy/easy_q6.py index 2a3d8c5..8a71db0 100644 --- a/problems/easy/easy_q6.py +++ b/problems/easy/easy_q6.py @@ -3,6 +3,13 @@ def print_numbers(n): i = 1 while i <= n: print(i) + + i+= 1 +if __name__ == "__main__": + num = int(input("Enter the Number: ")) + res = print_numbers(num) + print(res) + i += 1 if __name__ == "__main__": @@ -13,3 +20,4 @@ def print_numbers(n): num = int(input("Enter the Number :")) print_numbers(num) + diff --git a/problems/medium/m1.py b/problems/medium/m1.py index e5d9805..e0424a5 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -1,37 +1,37 @@ -''' -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 +39,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 +