forked from bloominstituteoftechnology/Intro-Python-I
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrock_paper_scissors
More file actions
76 lines (62 loc) · 2.16 KB
/
Copy pathrock_paper_scissors
File metadata and controls
76 lines (62 loc) · 2.16 KB
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
68
69
70
71
72
73
74
75
'''
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.
'''
#module that allows us to select a random number
import random
#dictionary
options = { {1, "rock"},
{2, "paper"},
{3, "scissors"} }
#load previous users from file into list
#TO-DO
text_file = open("results.txt", "rw")
lines = text_file.read().split(',')
print lines
print len(lines)
text_file.close()
#welcome message
print("Welcome to Rock, Paper, Scissors!")
name = ("Please enter your name.")
#initialize user, computer choices
print("Please choose to continue...")
computer = random.randint(1,3)
choice = int( input("[1] Rock [2] Paper [3] Scissors [9] Quit Game\n") )
print( choice )
#game will continue as long as user does not chose 9
while not choice == 9:
#user entered invalid option
if not(( choice == 1 ) or ( choice == 2 ) or ( choice == 3 )):
print( "Invalid selection. Choose again.")
choice = input("[1] Rock [2] Paper [3] Scissors [9] Quit Game\n")
#user chose ROCK
elif choice == 1:
if( computer == 1 ):
print( "Computer chose rock. Tie!" )
elif( computer == 2 ):
print( "Computer chose paper. You lose :( ")
else:
print( "Computer chose scissors. You win :)" )
#user chose PAPER
elif choice == 2:
if( computer == 1 ):
print( "Computer chose rock. You win :)" )
elif( computer == 2 ):
print( "Computer chose paper. Tie! ")
else:
print( "Computer chose scissors. You lose :(" )
#user chose SCISSORS
else:
if( computer == 1 ):
print( "Computer chose rock. You lose :(" )
elif( computer == 2 ):
print( "Computer chose paper. You win :) ")
else:
print( "Computer chose scissors. Tie! " )
print("\nPlease choose to continue...")
#prompt user to make another selection
computer = random.randint(1, 3)
choice = input("[1] Rock [2] Paper [3] Scissors [9] Quit Game\n")
#implement ??? as a function
#TO-DO