概述
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)
最后
以上就是迷你朋友为你收集整理的python的图形效果的全部内容,希望文章能够帮你解决python的图形效果所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复