python输入整数n ,绘制边长为n的正五边形
import turtle as t
def get_length():
length = input("Please enter a positive number as the length: ")
if length.replace(".","").isdigit():
return float(length)
else:
return get_length()
def main():
length = get_length()
t.circle(length,360,5)
t.exitonclick()
main()
python怎么画出一个五角星,要动态效果
fromturtleimportTurtle
t=Turtle();
t.speed(3);
t.pensize(5);
t.color('black','red');
t.begin_fill();
foriinrange(5):
t.forward(200);
t.right(144);
t.end_fill();
perl svg 怎么画 三角形
楼主可以尝Circos环形图很漂亮。Perl的话只能SVG做图,不是很好编程,也美观。R/matlab/python也有相应的教程。其实工具不重要,主要是坐标转换的问题,画出来的矢量图用AdobeIllustrator可以美化的。
怎么用python画三角形并填色?以及画五角星并且填色?(急!!!)
可. fill='#XXXXXX':
from Tkinter import Tk, Canvas, Frame, BOTH
from math import sin, pi,cos
def pentagramPoints(cx, cy, R):
xita = 36*pi/180
r = R*cos(2*xita)/cos(xita)
points = []
for i in range(0, 10):
angle = i*xita 0.5*xita
if i % 2:
points =[cx r*cos(angle), cy - r*sin(angle)]
else:
points =[cx R*cos(angle), cy - R*sin(angle)]
return points
if __name__ == '__main__':
root = Tk()
f = Frame(root)
f.pack(fill=BOTH, expand=1)
canvas = Canvas(f)
canvas.create_polygon(30, 10, 160, 470, 290, 10, outline="#000000", fill="#00ff00", width=3)
canvas.create_polygon(pentagramPoints(480, 240, 100), outline = '#000000', fill='#ff0000', width=3)
canvas.pack(fill=BOTH, expand=1)
root.geometry("640x480 300 300")
root.mainloop()
如何采用Python语言绘制一个五角星
#!/usr/bin/env python
import turtle
import time
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
time.sleep(1)
turtle.right(144)
turtle.forward(100)
time.sleep(3)
如何用python画一个五角星
全部
#/usr/bin/env
python
import
turtle
import
time
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
time.sleep(1)
turtle.right(144)
turtle.forward(100)
time.sleep(3)
如何用python的turtle画五角星
turtle.seth(angle):只改变海龟的行进方向(角度按逆时针),但不行进,angle为绝对度数
版权声明:本站所有文章皆为原创,欢迎转载或转发,请保留网站地址和作者信息。