IHateMyselfx

Useless garbage

Jul 21st, 2022
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.95 KB | None | 0 0
  1. import sys as q
  2. import random as rnd
  3. import pyttsx3 as tts
  4.  
  5.  
  6. def Game_Words():
  7.     szoveg = ['apple','far','weight','price','king','sight','car','blue','red','orange','range','lit','crown','love','low','flow','support']
  8.     shuffeled = []
  9.     shuffeled = szoveg.copy()
  10.    
  11.     rnd.shuffle(shuffeled)
  12.     yes_no = input("Can we start the game? (yes/no)\n:")
  13.     if yes_no == "yes" or "YES":
  14.         print("game started",end="."*5)
  15.         print()
  16.         Game_say(shuffeled)
  17.  
  18.  
  19. def Game_say(shuffeled):
  20.     Correct_guess = 0
  21.     answers = []
  22.     rate = engine.getProperty('rate')
  23.     engine.setProperty('rate', rate-66)
  24.     engine.say(shuffeled[0:5])
  25.     engine.runAndWait()
  26.     mem = 1
  27.     print(shuffeled[0:5])
  28.     for x in shuffeled[0:5]:
  29.         first = input(f"The {mem} world you heard:\n")
  30.         Correct_guess += Game_check_answers(shuffeled,first)
  31.         mem += 1
  32.         answers.append(first)
  33.    
  34.     Game_end_screen(Correct_guess,mem)
  35.  
  36.  
  37.    
  38.     print("Guesses: "+str(Correct_guess))
  39.  
  40. def Game_check_answers(shuffeled,first):
  41.         for t in shuffeled:
  42.  
  43.             if t == first:
  44.                 print("it was right ")
  45.                 #print(f" ""debug""" : T VALUE: :{t}, AND OUR INPUT: {first}")
  46.                 shuffeled.pop(0)
  47.                
  48.                 return 1
  49.             else:
  50.                 print("it was wrong ")
  51.                 shuffeled.pop(0)
  52.                 #print(f" ""debug""" : T VALUE: :{t}, AND OUR INPUT: {first}")
  53.                
  54.                 return 0
  55.  
  56.  
  57. def Game_end_screen(Correct_guess,mem):
  58.     print(f"You heard {mem-1} world")
  59.     percent = int((Correct_guess/(mem-1))*100)
  60.     print(f"Your accuracy was: {percent}%")
  61.     print("-----------------------\n")
  62.     if input("Do you wanna play again? \n: ") == "yes":
  63.         Game_Words()
  64.     else:
  65.        
  66.         q.exit("Bye")
  67.            
  68.    
  69.    
  70.    
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. engine = tts.init()
  87.  
  88.  
  89. Game_Words()
  90.  
Advertisement
Add Comment
Please, Sign In to add comment