Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys as q
- import random as rnd
- import pyttsx3 as tts
- def Game_Words():
- szoveg = ['apple','far','weight','price','king','sight','car','blue','red','orange','range','lit','crown','love','low','flow','support']
- shuffeled = []
- shuffeled = szoveg.copy()
- rnd.shuffle(shuffeled)
- yes_no = input("Can we start the game? (yes/no)\n:")
- if yes_no == "yes" or "YES":
- print("game started",end="."*5)
- print()
- Game_say(shuffeled)
- def Game_say(shuffeled):
- Correct_guess = 0
- answers = []
- rate = engine.getProperty('rate')
- engine.setProperty('rate', rate-66)
- engine.say(shuffeled[0:5])
- engine.runAndWait()
- mem = 1
- print(shuffeled[0:5])
- for x in shuffeled[0:5]:
- first = input(f"The {mem} world you heard:\n")
- Correct_guess += Game_check_answers(shuffeled,first)
- mem += 1
- answers.append(first)
- Game_end_screen(Correct_guess,mem)
- print("Guesses: "+str(Correct_guess))
- def Game_check_answers(shuffeled,first):
- for t in shuffeled:
- if t == first:
- print("it was right ")
- #print(f" ""debug""" : T VALUE: :{t}, AND OUR INPUT: {first}")
- shuffeled.pop(0)
- return 1
- else:
- print("it was wrong ")
- shuffeled.pop(0)
- #print(f" ""debug""" : T VALUE: :{t}, AND OUR INPUT: {first}")
- return 0
- def Game_end_screen(Correct_guess,mem):
- print(f"You heard {mem-1} world")
- percent = int((Correct_guess/(mem-1))*100)
- print(f"Your accuracy was: {percent}%")
- print("-----------------------\n")
- if input("Do you wanna play again? \n: ") == "yes":
- Game_Words()
- else:
- q.exit("Bye")
- engine = tts.init()
- Game_Words()
Advertisement
Add Comment
Please, Sign In to add comment