Commit 3fb3ac1c by BellCodeEditor

auto save

parent 23dfff73
Showing with 51 additions and 0 deletions
a=input("请输入第一个数字:")
b=input("请输入第二个数字:")
int(a)
int(b)
print(str(a*b))
# 玩家出拳
player = input("请出拳(石头/剪刀/布):")
print("玩家出拳:" + player)
# 计算机出拳
import random
list=["石头","剪刀","布"]
computer=random.choice(list)
print(computer)
\ No newline at end of file
# 完善游戏
# 写代码时习惯把需要导入的模块放在最前,老师可以和学生讲下,养成好习惯
# 前面练习时没关系,因为是正向设计目的是把代码写出来,最后整理下代码
import random
import time
print(".__ .__ .__ ")
print("| |__ ____ | | | | ____ ")
print("| | \_/ __ \| | | | / _ \ ")
print("| Y \ ___/| |_| |_( <_> )")
print("|___| /\___ >____/____/\____/ ")
print(" \/ \/ ")
print(" "+"欢迎来到我的游戏!!!")
time.sleep(1)
player = input("请出拳(石头/剪刀/布):")
print("∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞")
time.sleep(1)
print(" "+"3")
time.sleep(1)
print(" "+"2")
time.sleep(1)
print(" "+"1")
list = ["石头","剪刀", "布"]
computer = random.choice(list)
print("∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞")
print("玩家出拳:"+player)
print("计算机出拳:"+computer)
print("∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞")
if player in list:
if player == computer:
print("游戏平局,再来一次吧")
elif (player=="石头" and computer=="剪刀")or(player=="剪刀" and computer=="布")or(player=="布" and computer=="石头"):
print("恭喜,你赢了")
else:
print("很遗憾,你输了")
else:
print("输入错误")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment