python的图形效果

python的图形效果

第一个:

 answer = input("do you wangt to see a sppiral?y/n:")
    if answer == "y":
        print("working...")
        import turtle
        t = turtle.Pen()
        t.width(2)
        for x in range(100):
            t.forward(x*2)
            t.left(89)
    
   print("Okay,we are done!")

第二个:

import turtle
t = turtle.Pen()
sides = int(turtle.numinput("number of sides","how many sides in your spiral?",4))
for m in range(5, 75):
    t.left(360/sides + 5)
    t.width(m//25+1)
    t.penup()
    t.forward(m*4)
    t.pendown()
    if (m%2 == 0):
        for n in range(sides):
            t.circle(m/3)
            t.right(360/sides)
    else:
        for n in range(sides):
            t.forward(m)
            t.right(360/sides)

第三个:

rainy = input("how is the weather? Is it raining?(y/n)").lower()
cold = input("Is it cold outside?(y/n)").lower()
if (rainy == "y" and cold == "y"):
    print("you'd better wear a raincoat.")
elif (rainy == "y" and cold != "y"):
    print("carry an umbrella with you.")
elif (rainy != "y" and cold == "y"):
    print("put on a jacket, it's cold out")
elif (rainy != "y" and cold != "y"):
    print("wear whatever you want, it's beautiful outside!")

第四个:

import turtle
t = turtle.Pen()
t.penup()
turtle.bgcolor("black")
sides = int(turtle.numinput("number of sides", "how many sides in your sprial of spirals?(2-6)", 4, 2, 6))
colors = ["red", "yellow", "blue", "green", "purple", "orange"]
for m in range(100):
    t.forward(m*4)
    position = t.position()
    heading = t.heading()
    print(position, heading)
    for n in range(int(m/2)):
        t.pendown()
        t.pencolor(colors[n%sides])
        t.forward(2*n)
        t.right(360/sides - 2)
        t.penup()
    t.setx(position[0])
    t.sety(position[1])
    t.setheading(heading)
    t.left(360/sides + 2)
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值