-
Notifications
You must be signed in to change notification settings - Fork 89
/
rock-paper-scissor.py
60 lines (42 loc) · 1.58 KB
/
rock-paper-scissor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from tkinter import *
import random
move = ["rock", "paper", "scissor"]
def fun():
computer = move[random.randint(0,2)]
player = var.get()
choose.config(text="Player choose " + player + " and computer choose " + computer)
if player==computer:
result.config(text="Its a Tie")
elif player=="rock":
if computer=="paper":
result.config(text="Computer Win")
elif computer=="scissor":
result.config(text="Player Win")
elif player=="paper":
if computer=="scissor":
result.config(text="Computer Win")
elif computer=="rock":
result.config(text="Player Win")
elif player=="scissor":
if computer=="rock":
result.config(text="Computer Win")
elif computer=="paper":
result.config(text="Player Win")
root = Tk()
#root.geometry('250x300')
global result, var, choose
var=StringVar()
Rock = Radiobutton(root, text="Rock", variable=var, value="rock")
Rock.grid(row=0, column=0, padx=10, pady=10)
Rock.select()
Paper = Radiobutton(root, text="Paper", variable=var, value="paper")
Paper.grid(row=0, column=1, padx=10, pady=10)
Scissor = Radiobutton(root, text="Scissor", variable=var, value="scissor")
Scissor.grid(row=0, column=2, padx=10, pady=10)
submit = Button(root, text="submit", command=fun)
submit.grid(row=1, column=0, padx=10, pady=10, columnspan=3)
choose = Label(root, text="")
choose.grid(row=2, column=0, padx=10, pady=10, columnspan=3)
result = Label(root, text="")
result.grid(row=3, column=0, padx=10, pady=10, columnspan=3)
root.mainloop()