forked from anilgtm1075/Hactober-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRock_Paper_Scissor_GUI.py
67 lines (49 loc) · 1.8 KB
/
Rock_Paper_Scissor_GUI.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
61
62
63
64
65
66
67
import random
from tkinter import *
def computer_guess():
return random.choice(['rock', 'paper', 'scissors'])
def result(human_choice, computer_choice):
global human_score
global computer_score
if human_choice == computer_choice:
print("Tie")
elif human_choice == 'rock':
if computer_choice == 'paper':
print("You lose!", computer_choice, "covers", human_choice)
computer_score += 1
else:
print("You win!", human_choice, "smashes", computer_choice)
human_score += 1
elif human_choice == 'paper':
if computer_choice == 'scissors':
print("You lose!", computer_choice, "cut", human_choice)
computer_score += 1
else:
print("You win!", human_choice, "covers", computer_choice)
human_score += 1
elif human_choice == 'scissors':
if computer_choice == 'rock':
print("You lose...", computer_choice, "smashes", human_choice)
computer_score += 1
else:
print("You win!", human_choice, "cut", computer_choice)
human_score += 1
print("Score: Human = ", human_score, "Computer = ", computer_score)
def main():
global human_score
global computer_score
human_score = 0
computer_score = 0
human_choice = ''
computer_choice = ''
root = Tk()
root.title("Rock, Paper, Scissors")
Label(root, text="Choose Your Weapon").pack()
Button(root, text="Rock", command=lambda: result(
'rock', computer_guess())).pack(fill="x")
Button(root, text="Paper", command=lambda: result(
'paper', computer_guess())).pack(fill="x")
Button(root, text="Scissors", command=lambda: result(
'scissors', computer_guess())).pack(fill="x")
root.mainloop()
main()