-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrock.py
50 lines (38 loc) · 1.58 KB
/
rock.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
# create a game using if condition statements
import random
while True:
choices = ["rock", "paper", "scissors"]
computer = random.choice(choices)
player = None
while player not in choices:
player = input("rock, paper, scissors? ").lower()
if player == computer:
print("It's a tie!")
elif player == "rock" and computer == "scissors":
print(f"You win! you chose {player} and computer chose {computer}")
elif player == "rock" and computer == "paper":
print(f"You lose! you chose {player} and computer chose {computer}")
elif player == "paper" and computer == "rock":
print(f"You win! you chose {player} and computer chose {computer}")
elif player == "paper" and computer == "scissors":
print(f"You lose! you chose {player} and computer chose {computer}")
elif player == "scissors" and computer == "paper":
print(f"You win! you chose {player} and computer chose {computer}")
elif player == "scissors" and computer == "rock":
print(f"You lose! you chose {player} and computer chose {computer}")
else:
print("Something went wrong!")
play_again = input("Would you like to play again? (y/n) ").lower()
if play_again == "n":
break
else:
print("\n")
continue
print("Thanks for playing!")
# create a python pyramid object using multiple numbers
multiples_of_two: list = [i for i in range(0, 21, 2)]
print(multiples_of_two)
def pyramid(height):
for i in range(height):
print(" " * (height - i - 1) + f"{multiples_of_two[i]}" * (2 * i - 1))
pyramid(5)