forked from LKnopf/Python_precourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomework_2.py
More file actions
27 lines (23 loc) · 1.16 KB
/
homework_2.py
File metadata and controls
27 lines (23 loc) · 1.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
# rock paper scissors
# Write a set of if/else/elif statements that compare two variables 'user_input' and 'computer_input'
# These variables contain the strings `rock`, `paper', or 'scissors'
# Implement the rules as if/else/elif statements after line 10 with an indentation of 4 spaces, see example (line 10+11)
# Return a string saying 'tied game', 'you win', or 'computer wins' after every statement
# If there is no error when you run the script, you succeded
# Push the solution in your repo
def rock_paper_scissors(user_input, computer_input):
if user_input is computer_input:
return 'tied'
elif user_input is 'rock' and computer_input is 'paper':
return 'computer wins'
elif user_input is 'rock' and computer_input is 'scissors':
return 'user wins'
else:
return 'else'
if __name__ == "__main__":
possibilities = ['rock', 'paper', 'scissors']
for user_choice in possibilities:
for computer_choice in possibilities:
print(rock_paper_scissors(user_choice, computer_choice))
if user_choice == computer_choice:
assert rock_paper_scissors(user_choice, computer_choice) is 'tied'