Commit 8742ffe5 by BellCodeEditor

auto save

parent 55e28e3a
Showing with 83 additions and 12 deletions
#导入random模块
#玩家出拳
player = input('玩家出拳:')
print("player:"+player)
# input()输入的内容都是字符串
#创建列表 用来存放石头剪刀布 alist
#计算机出拳:通过random.choice()
#输出一下计算机出拳
#如果玩家等于计算机 就平局
#如果玩家出石头 and 计算机出剪刀 or 玩家出布and计算机出石头 or 玩家出剪刀and计算机出布 玩家获胜
#else: 计算机获胜
\ No newline at end of file
条件判断语句
单分支条件判断语句
if 条件:
条件成立时执行的语句
双分支条件判断语句
if 条件:
条件成立时执行的语句
else:
条件不成立时执行的语句
多分支条件判断语句 elif可以出现多次 当有一个分支成立时就不会执行其他分支
if 条件:
条件成立时执行的语句
elif 条件1
条件1成立时执行的语句
elif 条件2
条件2成立时执行的语句
elif 条件3
条件3成立时执行的语句
else:
条件不成立时执行的语句
\ No newline at end of file
# 上节课你是这样绘制的五角星👇:
# 这节课你可以利用新学的知识自定义五角星的颜色么?
import turtle
ink = input("什么色?")#绘制五角星#
pen = turtle.Pen()
pen.fillcolor(ink)
pen.begin_fill()
for i in range(5): #重复执行5次
pen.forward(200) #向前移动200步
pen.right(144) #向右移动144度,注意这里的参数一定不能变
pen.end_fill() #结束填充红色
turtle.done()
import random
while True:
a=input("石头/剪刀/布")
if a != "石头" and "剪刀" and "布":
print("plz retype")
break
else:
if a=="石头":
b=1
if a=="剪刀":
b=2
if a=="布":
b=3
print("玩家出"+a)
c=random.randint(1,3)
if c ==1:
print("人机出石头")
if c ==2:
print("人机出剪刀")
if c ==3 :
print("人机出布")
if c==b:
print("平局")
if b==1 and c==2:
print("玩家赢")
if b==2 and c == 3:
print("玩家赢")
if b==3 and c==1:
print("玩家赢")
if c==1 and b ==2:
print("人机赢")
if c==2 and b ==3:
print("人机赢")
if c==3 and b ==1:
print("人机赢")
\ No newline at end of file
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