利用python编程小海龟库绘制五角星,菱形,同心圆,等边三角形,四瓣小花,波浪曲线等代码

#小海龟绘制五角星
import turtle
count = 1
while count <= 5:
    turtle.forward(100)
    turtle.right(144)
    count += 1
turtle.pendown()
turtle.left(36)
count = 1
while count <= 5:
    turtle.left(72)
    turtle.backward(62.5)
    count += 1
turtle.pendown()
#小海龟绘制菱形
import turtle
t=turtle.pen()
turtle.speed(1)
turtle.left(60)
turtle.forward(100)
turtle.left(60)
turtle.forward(100)
turtle.left(120)
turtle.forward(100)
turtle.left(60)
turtle.forward(100)
turtle.right(180)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(120)
turtle.forward(50)
turtle.right(120)
turtle.forward(100)
turtle.right(60)
turtle.forward(50)
turtle.right(120)
turtle.forward(50)
turtle.right(60)
turtle.forward(100)
turtle.down()
#绘制五边形和五角星
import  turtle
t=turtle.pen()
turtle.speed(1)
turtle.pen('purple')
count=1
while count<=5:
    turtle.fd(100)
    turtle.left(72)
    count=count+1
turtle.down()
turtle.left(72)

count=1
while count<=5:
    turtle.fd(160)
    turtle.right(144)
    count=count+1
turtle.done()

#python画同心圆
import turtle
r = 0
for i in range(6):
    r+=30 #自己设
    turtle.circle(r)#画个圆
    turtle.penup()#起笔
    turtle.sety(-r)#移动笔的位置
    turtle.pendown()#落笔



#pythyon画叠加等边三角形
import turtle
turtle.speed(2)
turtle.fd(200)
turtle.left(120)
turtle.fd(400)
turtle.left(120)
turtle.fd(400)
turtle.left(120)
turtle.fd(200)
turtle.left(120)
turtle.fd(200)
turtle.right(120)
turtle.fd(200)
turtle.right(120)
turtle.fd(200)
turtle.done()




#用python画四瓣小花(1)
'''import turtle
turtle.speed(5)
turtle.color("red")
turtle.circle(40,180)
turtle.seth(90)
turtle.circle(40,180)
turtle.seth(180)
turtle.circle(40,180)
turtle.seth(270)
turtle.circle(40,180)
turtle.done()'''
#用python画四瓣小花(2)
'''import turtle
turtle.speed(1)
turtle.color("red")
for i in range(4):
  turtle.circle(50,180)
  turtle.left(90)
turtle.done()'''
#用python画波浪曲线
'''import turtle
turtle.speed(4)
turtle.color("blue")
n=int(input("请输入半圆的个数,为偶数个:"))
r=int(input("请输入半圆的半径:"))
for i in range(n):
  turtle.seth(90)
  turtle.circle(-r,180)
  turtle.circle(r,180)
  
turtle.done()'''
  #python绘制圆和圆弧的结合
import turtle
turtle.speed(3)
turtle.color("red")
turtle.circle(48.3)
turtle.seth(90)
for i in range(4):
    turtle.circle(-48.3,90)
    turtle.right(180)
turtle.circle(48.3,45)
turtle.circle(-20)
turtle.circle(-20,45)
turtle.seth(180)
turtle.right(180)
for i in range(4):
    turtle.circle(-20,90)
    turtle.right(180)
turtle.done()    
python练习绘制叶子的组合
# import turtle as t 
# t.speed(4)
# t.color("red")
# for i in range(5):
#     t.fd(80)
#     t.rt(144)
#     t.fd(80)
#     t.lt(72)
# t.fd(80)
# t.rt(54)
# for i in range(5):
#     t.circle(-80,108)
#     t.lt(36)
# t.done()

    
    

    
  
   









  

你可能感兴趣的:(python,python,信息可视化,开发语言)