本文目录一览:
- 1、用Python matplotlib 怎么画风向玫瑰图 能给出程序的
- 2、python100元买花,百合5,玫瑰3,康乃馨1元3,100元整能买多少百合玫瑰康
- 3、python怎么画玫瑰花
- 4、玫瑰花代码怎么敲
- 5、怎么用python画玫瑰花,求大神贴代码,感激不尽
用Python matplotlib 怎么画风向玫瑰图 能给出程序的
import numpy as np
import matplotlib.pyplot as plt
N = 20
theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)
radii = 10 * np.random.rand(N)
width = np.pi / 4 * np.random.rand(N)
ax = plt.subplot(111, projection='polar')
bars = ax.bar(theta, radii, width=width, bottom=0.0)
# Use custom colors and opacity
for r, bar in zip(radii, bars):
bar.set_facecolor(plt.cm.jet(r / 10.))
bar.set_alpha(0.5)
plt.show()
差不多上面代码的原理,具体的自己照着官方文档改
python100元买花,百合5,玫瑰3,康乃馨1元3,100元整能买多少百合玫瑰康
for x in range(20):
for y in range(34):
z = 100 - y - x
if 5 * x + 3 * y + z / 3 == 100:
print('百合:', x, '玫瑰:', y, '康乃馨:', z)
百合: 0 玫瑰: 25 康乃馨: 75
百合: 4 玫瑰: 18 康乃馨: 78
百合: 8 玫瑰: 11 康乃馨: 81
百合: 12 玫瑰: 4 康乃馨: 84
python怎么画玫瑰花
操纵海龟绘图有着许多的命令,这些命令可以划分为两种:一种为运动命令,一种为画笔控制命令
1. 运动命令:
forward(degree) #向前移动距离degree代表距离
backward(degree) #向后移动距离degree代表距离
right(degree) #向右移动多少度
left(degree) #向左移动多少度
goto(x,y) #将画笔移动到坐标为x,y的位置
stamp() #复制当前图形
speed(speed) #画笔绘制的速度范围[0,10]整数
2. 画笔控制命令:
down() #移动时绘制图形,缺省时也为绘制
up() #移动时不绘制图形
pensize(width) #绘制图形时的宽度
color(colorstring) #绘制图形时的颜色
fillcolor(colorstring) #绘制图形的填充颜色
fill(Ture)
fill(false)
lucy : 梦想照进现实;露茜;青春风采;
draw_flower1.py
[python] view plain copy
# -*- coding: cp936 -*-
import turtle
import math
def p_line(t, n, length, angle):
"""Draws n line segments."""
for i in range(n):
t.fd(length)
t.lt(angle)
def polygon(t, n, length):
"""Draws a polygon with n sides."""
angle = 360/n
p_line(t, n, length, angle)
def arc(t, r, angle):
"""Draws an arc with the given radius and angle."""
arc_length = 2 * math.pi * r * abs(angle) / 360
n = int(arc_length / 4) + 1
step_length = arc_length / n
step_angle = float(angle) / n
# Before starting reduces, making a slight left turn.
t.lt(step_angle/2)
p_line(t, n, step_length, step_angle)
t.rt(step_angle/2)
def petal(t, r, angle):
"""Draws a 花瓣 using two arcs."""
for i in range(2):
arc(t, r, angle)
t.lt(180-angle)
def flower(t, n, r, angle, p):
"""Draws a flower with n petals."""
for i in range(n):
petal(t, r, angle)
t.lt(p/n)
def leaf(t, r, angle, p):
"""Draws a 叶子 and fill it."""
t.begin_fill() # Begin the fill process.
t.down()
flower(t, 1, 40, 80, 180)
t.end_fill()
def main():
window=turtle.Screen() #creat a screen
window.bgcolor("blue")
lucy=turtle.Turtle()
lucy.shape("turtle")
lucy.color("red")
lucy.width(5)
lucy.speed(0)
# Drawing flower
flower(lucy, 7, 60, 100, 360)
# Drawing pedicel
lucy.color("brown")
lucy.rt(90)
lucy.fd(200)
# Drawing leaf
lucy.rt(270)
lucy.color("green")
leaf(lucy, 40, 80, 180)
lucy.ht()
window.exitonclick()
main()
玫瑰花代码怎么敲
1.在电脑桌面,鼠标右键单击选择 新建文本文档,新建一个文本文档。
2.选择新建的文本,右键选择重命名为,meigui.html,然后确定,选择是。
3.用记事本打开文件,复制下面的代码到文件中,保存。
htmlheadtitle情人节玫瑰/titlemeta http-equiv="Content-Type" content="text/html; charset=gb2312" /style type="text/css"#shusheng {position: absolute;width: 100%;height: 100%;text-align: center;}/style/headbodydiv style="text-align: center"h1送给xxx的花/h1/divdiv id="shusheng"canvas id="c"/canvas scriptvar b = document.body;var c = document.getElementsByTagName('canvas')[0];var a = c.getContext('2d');document.body.clientWidth; /scriptscriptwith(m=Math)C=cos,S=sin,P=pow,R=random;c.width=c.height=f=500;h=-250;function p(a,b,c){if(c60)return[S(a*7)*(13+5/(.2+P(b*4,4)))-S(b)*50,b*f+50,625+C(a*7)*(13+5/(.2+P(b*4,4)))+b*400,a*1-b/2,a];A=a*2-1;B=b*2-1;if(A*A+B*B1){if(c37) {n=(j=c1)?6:4;o=.5/(a+.01)+C(b*125)*3-a*300;w=b*h;return[o*C(n)+w*S(n)+j*610-390,o*S(n)-w*C(n)+550-j*350,1180+C(B+A)*99-j*300,.4-a*.1+P(1-B*B,-h*6)*.15-a*b*.4+C(a+b)/5+P(C((o*(a+1)+(B0?w:-w))/25),30)*.1*(1-B*B),o/1e3+.7-o*w*3e-6]}if(c32) {c=c*1.16-.15;o=a*45-20;w=b*b*h;z=o*S(c)+w*C(c)+620;return[o*C(c)-w*S(c),28+C(B*.5)*99-b*b*b*60-z/2-h,z,(b*b*.3+P((1-(A*A)),7)*.15+.3)*b,b*.7]}o=A*(2-b)*(80-c*2);w=99-C(A)*120-C(b)*(-h-c*4.9)+C(P(1-b,7))*50+c*2;z=o*S(c)+w*C(c)+700;return[o*C(c)-w*S(c),B*99-C(P(b, 7))*50-c/3-z/1.35+450,z,(1-b/1.2)*.9+a*.1, P((1-b),20)/4+.05]}}setInterval('for(i=0;i1e4;i++)if(s=p(R(),R(),i%46/.74)){z=s[2];x=~~(s[0]*f/z-h);y=~~(s[1]*f/z-h);if(!m[q=y*f+x]|m[q]z)m[q]=z,a.fillStyle="rgb("+~(s[3]*h)+","+~(s[4]*h)+","+~(s[3]*s[3]*-80)+")",a.fillRect(x,y,1,1)}',0)/script/div/body/html
4.然后用浏览器打开文件,是不是出现了一朵漂亮的 玫瑰花,大功告成。
怎么用python画玫瑰花,求大神贴代码,感激不尽
import turtle
# 设置初始位置
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)
# 花蕊
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(10, 180)
turtle.circle(25, 110)
turtle.left(50)
turtle.circle(60, 45)
turtle.circle(20, 170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30, 110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90, 70)
turtle.circle(30, 150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80, 90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150, 80)
turtle.left(50)
turtle.circle(150, 90)
turtle.end_fill()
# 花瓣1
turtle.left(150)
turtle.circle(-90, 70)
turtle.left(20)
turtle.circle(75, 105)
turtle.setheading(60)
turtle.circle(80, 98)
turtle.circle(-90, 40)
# 花瓣2
turtle.left(180)
turtle.circle(90, 40)
turtle.circle(-80, 98)
turtle.setheading(-83)
# 叶子1
turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(-80, 90)
turtle.right(90)
turtle.circle(-80, 90)
turtle.end_fill()
turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)
# 叶子2
turtle.right(90)
turtle.right(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(80, 90)
turtle.left(90)
turtle.circle(80, 90)
turtle.end_fill()
turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200, 60)
运行结果: