刚刚起步python,觉得python turtle真是萌神一般的存在呀~ 试着画了颗“心”,不过觉得方法实在是太笨了> < 想求问各位老小伙伴,还有什么方法可以python/python turtle画“心”呢?回复内容:
from turtle import *
def curvemove():
for i in range(200):
right(1)
forward(1)
color(‘red’,’pink’)
begin_fill()
left(140)
forward(111.65)
curvemove()
left(120)
curvemove()
forward(111.65)
end_fill()
done()
from turtle import *from turtle import *pensize(1)color(‘black’,’red’)speed(2)up()goto(-12,100)down()begin_fill()left(90)circle(120,180)circle(360,70.529)left(38.942)circle(360,70.529)circle(120,180)end_fill()up()goto(-250,-150)down()
from pylab import*
t=linspace(0,2*pi,100)
x=sin(2*t) + 2*sin(t)
y=-cos(2*t)-2*cos(t)
fill(x,y,’r’)
show()
心没画,玫瑰花倒是有一个之前忘了帖代码,现在补上。之前忘了帖代码,现在补上。for i in range (1): def paint(ang,r,ang2): #画图函数 turtle.penup() turtle.setheading(ang) turtle.pendown() turtle.circle(r,ang2) import turtle turtle.speed(9) turtle.color(“white”) #设置 turtle.pensize(7) turtle.penup() turtle.goto(50,-50) turtle.pendown() turtle.dot(200,”pink”) #画背景 turtle.penup() turtle.goto(50,86.6) ang=-150 r=300 ang2=46 for j in range (21): #循环 paint(ang,r,ang2) #画弧 ang2-=25 paint(ang+ang2+25,r,-ang2) #回退 ang2+=25 ang+=66 r=r*0.9思路大概就是:画圆弧,回退大约1/3,转向,减小半径,画圆弧……一直循环…视频传送门python玫瑰花_生活提醒我贴代码的那个小同学,我看了你资料,看来你和我一个学校而且选的同一个选修课呢。不过我这个作业交过了,所以你参考一下,不懂的可以问我。照抄的话老师会打你屁屁的(╯‵□′)╯︵┻━┻。35道哪个不会可以私信我。我给你思路~不过最近考试周,我不一定都能帮得上忙。。。————–15.12.31—————–
import sys
import math
def frange(start, end, step=1.0):
if step > 0:
while start < end:
yield start
start += step
elif step < 0:
while start > end:
yield start
start += step
else:
raise valueerror(‘range() step must not be zero’)
def f(x, y, z):
a = x*x + 9.0/4*y*y + z*z – 1
return a*a*a – x*x*z*z*z – 9.0/80*y*y*z*z*z
def h(x, z):
for y in frange(1.0, 0.0, -0.001):
if f(x, y, z)