用户:
小泥皮查看:0 回复:3 评论:0 创建时间:2023-06-27T21:53:26
本人是新手,第一次发帖,请各位大佬指教。
from turtle import *
def draw_circle(size=1, x=0, y=0, r=1, c='black', v=0, fillcolour='white'):
# size参数为画笔粗细,参数x和y为坐标,参数r为圆的半径,参数c为画笔颜色,参数v为速度,参数fillcolour为填充颜色。
# 以下为主程序
print('Welcome to use draw_circle function!')
# 设置画笔粗细
pensize(size)
# 设置画笔颜色
color(c)
# 设置填充颜色
fillcolor(fillcolour)
# 设置绘画速度
speed(v)
# 移动到x, y坐标
penup()
goto(x, y)
# 开始填充
begin_fill()
pendown()
# 画圆
circle(r)
end_fill()
done()
# 调用
draw_circle(3, 0, 1, 100, 'red', 0, 'red')点赞0
评论
# coding=UTF-8
import random
while True:
# 计算机随机生成1~3之间的数
a = random.randint(1, 3)
# 检测用户是否输入非1~3的其他文字,如果是,进入下一轮循环
try:
b = int(input('1-剪刀 2-石头 3-布 '))
except:
print('输入的是无效字符')
continue
print('计算机出的数字是', a)
print('我出的数字是', b)
# 检测输入的数是否大于3,小于1
if b > 3 or b< 1:
print('请输入1~3')
continue
# 计算分数
if a == b:
print('平局')
elif a==2 and b==1:
print('计算机赢')
elif a==1 and b==2:
print('玩家赢')
elif a==1 and b==3:
print('计算机赢')
elif a==3 and b==1:
print('玩家赢')
elif a==2 and b==3:
print('玩家赢')
else:
print('计算机赢')
# 是否结束
i = str(input('是否结束?y/n '))
if i == 'n':
continue
elif i == 'y':
break
# 其他结果处理
else:
print('此为无效字符')
break点赞0
评论