Commit ccd013b6 by BellCodeEditor

save project

parent 8b0ac80c
Showing with 42 additions and 5 deletions
name = input("勇于挑战的创造师你叫什么呀?")
print(name+",你好呀")
\ No newline at end of file
import turtle
pen1=turtle.Pen()
pen1.pensize(10)
pen1.pencolor("black")
pen1.left(45)
pen1.forward(100)
pen1.circle(50,180)
pen1.right(90)
pen1.circle(50,180)
pen1.forward(100)
pen1.hideturtle()
turtle.done()
s=input("请输入颜色")
a=input("请输入边数")
color=input("请输入颜色")
bianshu=input("请输入边数")
import random
import turtle
import sys
if bianshu=="随机":
bianshuint=random.randrange(1,10)
else:
if bianshu.isdigit()and int(bianshu) !=0:
bianshuint=int(bianshu)
else:
print("边数输入错误")
sys.exit(0)
colorlist=["red","yellow","blue","black","green","pink"]
if color=="随机":
color=random.choice(colorlist)
else:
if color not in colorlist:
print("颜色输入错误")
p=turtle.Pen()#4.1画笔
p.color(color)#4.2画笔颜色
p.fillcolor(color)#4.3填充颜色
p.begin_fill()#4.4填充开始
#(n-2)*180(n==边数)
angle=180*(bianshuint-2)/bianshuint#n边形内角和除以n得到n边形外角的值
for i in range(bianshuint):
p.forward(1)
p.left(180-angle)#求补角得到内角
p.end_fill()#4.5填充结束
p.hideturtle()#4.6隐藏
turtle.done()
\ 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