Guest User

Untitled

a guest
Dec 19th, 2021
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. import random
  2. from tkinter import *
  3. from time import sleep
  4. root = Tk()
  5. root['bg'] = 'Gray'
  6. root.geometry('700x500')
  7. root.title('2Games')
  8. root.resizable(width=False, height=False)
  9. def rand_num():
  10. num345 = random.randint(1, 100)
  11. print(num345)
  12. while og != num345:
  13. if og < num345:
  14. print("Число больше")
  15. elif og > num345:
  16. print("Число меньше")
  17. else:
  18. print("Вы угадали")
  19. sleep(1)
  20. def paper():
  21. rand = random.choice(["Ножницы", "Камень", "Бумага"])
  22. print("Дайте мне время выбрать")
  23. sleep(1)
  24. print("Думаю...")
  25. sleep(1)
  26. print(".")
  27. sleep(1)
  28. print(".")
  29. sleep(1)
  30. print(".")
  31. if rand == "Ножницы":
  32. if choice2 == '1':
  33. print("Вы выбрали ножницы, я выбрал ножницы, ничья")
  34. elif choice2 == '2':
  35. print("Вы выбрали камень, я выбрал ножницы, вы выиграли.")
  36. elif choice2 == '3':
  37. print("Вы выбрали бумагу, я выбрал ножницы, вы проиграли.")
  38. else:
  39. print('Такого ответа нет, вы проиграли')
  40. elif rand == "Камень":
  41. if choice2 == '1':
  42. print("Вы выбрали ножницы, я выбрал камень, вы проиграли.")
  43. elif choice2 == '2':
  44. print("Вы выбрали камень, я выбрал камень, ничья.")
  45. elif choice2 == '3':
  46. print("Вы выбрали бумагу, я выбрал камень, вы выиграли")
  47. else:
  48. print('Такого ответа нет, вы проиграли')
  49.  
  50. elif rand == "Бумага":
  51. if choice2 == '1':
  52. print("Вы выбрали ножницы, я выбрал бумагу, вы выиграли")
  53. elif choice2 == '2':
  54. print("Вы выбрали камень, я выбрал бумагу, вы проиграли")
  55. elif choice2 == '3':
  56. print("Вы выбрали бумагу, я выбрал бумагу, ничья")
  57. else:
  58. print('Такого ответа нет, вы проиграли')
  59. def cho():
  60. global choice2
  61. choice2 = vvod.get()
  62. def num333():
  63. global og
  64. og = rest.get()
  65. og = int
  66. b2 = Button(root, text='Камень-ножницы-бумага', bg = 'DarkGrey', command=paper)
  67. b2.place(x=0, y=45, width=160, height=100)
  68. b1 = Button(root, text='Угадай число', bg = 'DarkGrey', command=rand_num)
  69. b1.place(x=0, y=170, width=160, height=100)
  70. vvod = Entry(root, bg = 'LightGray')
  71. vvod.place(x=0, y=20, width=650, height=24)
  72. but = Button(root, text='Выбрать', bg = 'DarkGrey', command=cho)
  73. but.place(x=645, y=20)
  74. poleText = Canvas(root, width = 700, height = 20, bg='Gray')
  75. poleText.create_text(130, 10, text='Выберите: 1-ножницы, 2-камень, 3-бумага', fill='white')
  76. poleText.pack()
  77. rest = Entry(root, bg = 'LightGray')
  78. rest.place(x=0, y=160, width=650, height=24)
  79. num23 = Canvas(root, width = 700, height = 20, bg='Gray')
  80. num23.place(x=0, y = 140)
  81. num23.create_text(100, 10, text='Введите число от 1 до 100', fill='white')
  82. ggnum = Button(root, text = "Выбрать", bg = 'DarkGrey', command=num333)
  83. ggnum.place(x=645, y = 160)
Advertisement
Add Comment
Please, Sign In to add comment