diff --git a/basic calculator.py b/basic calculator.py index 57cfff1..41aad3a 100644 --- a/basic calculator.py +++ b/basic calculator.py @@ -1,44 +1,70 @@ def add(a, b): answer = a + b - print(str(a) + " + " + str( b) + " = " + str(answer) + "\n") + print(str(a) + " + " + str(b) + " = " + str(answer) + "\n") + def sub(a, b): answer = a - b - print(str(a) + " - " + str(b ) + " = " + str(answer) + "\n") -def mul(a, b): - answer = a*b + print(str(a) + " - " + str(b) + " = " + str(answer) + "\n") + +def mul(a,b): + answer = a * b print(str(a) + " * " + str(b) + " = " + str(answer) + "\n") -def div(a, b): + +def div(a,b): answer = a / b print(str(a) + " / " + str(b) + " = " + str(answer) + "\n") +def pow(a,b): + answer = a ** b + print(str(a) + " ** " + str(b) + " = " + str(answer) + "\n") + +def modulo(a,b): + answer = a % b + print(str(a) + " % " + str(b) + " = " + str(answer) + "\n") + while True: + print("Choose operator you want! Can Just Input Integer Number") print("A. Addition") - print("B. Subtraction") + print("B. Substraction") print("C. Multiplication") print("D. Division") - print("E. Exit") - choice = input("input your choice: ") + print("E. Pow") + print("F. Modulo") + print("G. Exit") + choice = input("Input Your Choice: ") + if choice == "a" or choice == "A": print("Addition") - a = int(input("input first number: ")) - b = int(input("input second number: ")) - add(a, b) + a = float(input("Input Number Here: ")) + b = float(input("Input Number Here: ")) + add(a,b) elif choice == "b" or choice == "B": - print("Subtraction") - a = int(input("input first number:")) - b = int(input("input second number: ")) - sub(a, b) + print("Substraction") + a = float(input("Input Number Here: ")) + b = float(input("Input Number Here: ")) + sub(a,b) elif choice == "c" or choice == "C": print("Multiplication") - a = int(input("input first number:")) - b = int(input("input second number: ")) - mul(a, b) + a = float(input("Input Number Here: ")) + b = float(input("Input Number Here: ")) + mul(a,b) elif choice == "d" or choice == "D": - print("Division" ) - a = int(input("input first number:")) - b = int(input("input second number: ")) - div(a, b) + print("Division") + a = float(input("Input Number Here: ")) + b = float(input("Input Number Here: ")) + div(a,b) elif choice == "e" or choice == "E": - print("program ended") + print("Pow") + a = float(input("Input Number Here: ")) + b = float(input("Input Number Here: ")) + pow(a,b) + elif choice == "f" or choice == "F": + print("Modulo") + a = float(input("Input Number Here: ")) + b = float(input("Input Number Here: ")) + modulo(a,b) + elif choice == "g" or choice == "G": + print("Game Ended") quit() + diff --git a/quiz program.py b/quiz program.py index 187626d..29106dd 100644 --- a/quiz program.py +++ b/quiz program.py @@ -1,49 +1,65 @@ -quiz = { - "question1": { - "question": "What is the capital of France?", - "answer": "Paris" - }, - "question2": { - "question": "What is the capital of Germany?", - "answer": "Berlin" - }, - "question3": { - "question": "What is the capital of Italy?", - "answer": "Rome" - }, - "question4": { - "question": "What is the capital of Spain?", - "answer": "Madrid" - },"question5": { - "question": "What is the capital of Portugal?", - "answer": "Lisbon" - },"question6": { - "question": "What is the capital of Switzerland?", - "answer": "Bern" - },"question7": { - "question": "What is the capital of Austria?", - "answer": "Vienna" - }, -} +def ask(): + quiz = { + "question1" : { + "question": "What is the capital of France?", + "answer": "Paris" + }, + "question2" : { + "question": "What is the capital of Germany?", + "answer": "Berlin" + }, + "question3" : { + "question": "What is the capital of Italy?", + "answer": "Roma" + }, + "question4" : { + "question": "What is the capital of Spain?", + "answer": "Madrid" + }, + "question5" : { + "question": "What is the capital of Portugal?", + "answer": "Lisbon" + }, + "question6" : { + "question": "What is the capital of Switzerland?", + "answer": "Bern" + }, + "question7" : { + "question": "What is the capital of Austria?", + "answer": "Vienna" + }, + + } -score = 0 + score = 0 -for key, value in quiz.items(): - print(value[' question' ]) - answer = input("Answer? ") + for key, value in quiz.items(): + print(value['question']) + answer = input("Answer? ") + + if answer.lower() == value['answer'].lower(): + print('Correct') + score = score + 1 + print("Your Score: " + str(score)) + print("") + print("") + else: + print("Wrong!") + print("The Answer is : " + value['answer']) + print("Your Score is : " + str(score)) + print("") + print("") - if answer.lower() == value[ 'answer'] . lower(): - print('Correct') - score = score + 1 - print("Your score is: " + str(score)) - print("") - print("") - else: - print("Wrong!") - print("The answer is : " + value[ ' answer']) - print("Your score is: " + str(score)) - print("") - print("") + print("You got " + str(score) + " out of 7 question correctly") + print("Your percentage is " + str(int(score/7 * 100)) + " %") -print("You got " + str(score) + " out of 7 questions correctly") -print("Your percentage is " + str(int(score/7 * 100)) + "%") + + while True: + replay = input("Still Wanna Play ? (y/n) ") + if replay == "Y" or replay == "y": + ask() + else: + quit() + +print("Welcome to Our Quiz!!") +ask() diff --git a/random password generator.py b/random password generator.py index 30796c9..c535dcb 100644 --- a/random password generator.py +++ b/random password generator.py @@ -1,30 +1,32 @@ import string import random -characters = list(string.ascii_letters + string.digits + " !@#$%^&*()") +characters = list(string.ascii_letters + string.digits + "!@#$%^&*()") def generate_password(): password_length = int(input("How long would you like your password to be? ")) - + random.shuffle(characters) - + password = [] - + for x in range(password_length): password.append(random.choice(characters)) - - random.shuffle(password) - - password = "" .join(password) - print(password) -option = input("Do you want to generate a password? (Yes/No): ") + random.shuffle(password) -if option == "Yes": - generate_password() -elif option == "No": - print("Program ended") - quit() -else: - print("Invalid input, please input Yes or No") - quit() + password = "".join(password) + print(password) + option = input("Do you still wanna generate a password? (y/n) ") # made option for replay game again + if option == 'Y' or option == 'y': + generate_password() + elif option == 'N' or option == 'n': + print('Program Ended') + quit() + else: + print("Invalid input, please input Y or N") + quit() + + +print('Welcome to Your Password Generator') +generate_password() diff --git a/word replacement.py b/word replacement.py index 814d9e2..69871be 100644 --- a/word replacement.py +++ b/word replacement.py @@ -1,7 +1,10 @@ def replace_word(): - str = "hi guys, i am tomi, and hi hi hi hi" - word_to_replace = input("Enter the word to replace: ") + str = input("Words i wanna type: ") #made word with input from user + word_to_replace = input("Enter The Word to replace: ") word_replacement = input("Enter the word replacement: ") print(str.replace(word_to_replace, word_replacement)) - + back = input("Still wanna play this game : (y/n) ? ") + if back == 'y' or back == 'Y': #made replay game if input = y or Y + return replace_word() + replace_word()