-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_py.py
More file actions
44 lines (31 loc) 路 1.21 KB
/
Copy pathpython_py.py
File metadata and controls
44 lines (31 loc) 路 1.21 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
import random
def rock_paper_scissors():
options = ["rock", "paper", "scissors"]
print("Welcome to Rock, Paper, Scissors!")
print("Options: rock, paper, scissors")
while True:
user_choice = input("Enter your choice (rock/paper/scissors): ").strip().lower()
if user_choice not in options:
print("Invalid choice. Please try again.")
continue
computer_choice = random.choice(options)
print(f"Computer chose: {computer_choice}")
if user_choice == computer_choice:
print("It's a draw! Try again.")
elif (user_choice == "rock" and computer_choice == "scissors") or \
(user_choice == "scissors" and computer_choice == "paper") or \
(user_choice == "paper" and computer_choice == "rock"):
print("You win! 馃帀")
break
else:
print("Computer wins! 馃捇")
break
rock_paper_scissors()
import string
print("ASCII letters:")
print(string.ascii_letters)
import string
from random import sample
five_letters = ''.join(sample(string.ascii_letters, 5))
print("Five randomly sampled letters:")
print(five_letters)