剪刀 石頭 布練習
unknown
plain_text
3 years ago
1.3 kB
6
Indexable
scissor = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
import random
import sys
user= input("請輸入字母s(剪刀)r(石頭)p(布)").lower()
if user == "s":
print (f"你出{scissor}")
elif user == "r":
print (f"你出{rock}")
elif user == "p":
print (f"你出{paper}")
else:
print("請輸入正確的選項s r 或p")
exit(0)
pc = ["s","r","p"]
random_pc = random.choice(["s","r","p"])
if random_pc == "s":
print (f"電腦出{scissor}")
elif random_pc == "r":
print (f"電腦出{rock}")
elif random_pc == "p":
print (f"電腦出{paper}")
if user == random_pc:
print ("平手")
if user == "s" and random_pc == "p":
print ("恭禧你贏了")
elif user == "s" and random_pc == "r":
print ("抱歉你輸了")
if user == "r" and random_pc == "s":
print("恭禧你贏了")
elif user == "r" and random_pc == "p":
print("抱歉你輸了")
if user == "p" and random_pc == "r":
print ("恭禧你贏了")
elif user == "p" and random_pc == "s":
print ("抱歉你輸了")
Editor is loading...