Advertisement
Norvager

Untitled

May 24th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. from random import randint as rand
  2. import readchar
  3.  
  4. endGame = False
  5.  
  6. print("Вводите символы которые видите на экране")
  7. pressedKey = None
  8. checkTrue = 0
  9. while True:
  10. if endGame:
  11. break
  12. kod = rand(65, 122)
  13. neededKey = chr(kod)
  14. print(neededKey, end = '', flush = True)
  15. pressedKey = readchar.readkey()
  16. if neededKey == pressedKey :
  17. checkTrue += 1
  18. if pressedKey == '\x1b' :
  19. print(f"\n Кол-во верных ответов: {checkTrue}")
  20. checkTrue = 0
  21. endGame = True
  22. break
  23. while neededKey != pressedKey :
  24. checkTrue = 0
  25. print("\n")
  26. print("Ошибка!")
  27. print("\b")
  28. print(neededKey, end = '', flush = True)
  29. pressedKey = readchar.readkey()
  30. if neededKey == pressedKey :
  31. checkTrue += 1
  32. if pressedKey == '\x1b' :
  33. print(f"Кол-во верных ответов: {checkTrue}")
  34. checkTrue = 0
  35. endGame = True
  36. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement