用python输出所有的玫瑰花数_##判断某一个四位数是不是玫瑰花数(所谓

用Python matplotlib 怎么画风向玫瑰图 能给出程序的

提前安windrose模

from windrose import WindroseAxes

from matplotlib import pyplot as plt

import matplotlib.cm as cm

from numpy.random import random

from numpy import arange

ws = random(500)*6

wd = random(500)*360

#A quick way to create new windrose axes...

def new_axes():

fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')

rect = [0.1, 0.1, 0.8, 0.8]

ax = WindroseAxes(fig, rect, axisbg='w')

fig.add_axes(ax)

return ax

#...and adjust the legend box

def set_legend(ax):

l = ax.legend(shadow=True, bbox_to_anchor=[-0.1, 0], loc='lower left')

plt.setp(l.get_texts(), fontsize=10)

ax = new_axes()

ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')

set_legend(ax)

plt.show()

用Python matplotlib 怎么画风向玫瑰图 能给出程序的

python(之前写过关于python的安装,这里不重复介绍)

(1)

如何下--->

Python官网

(2)

版本:python-3.4.3.amd64

exe文件直接点哦

(3)

目D:\Python34

为python配置了环境变量:D:\Python34\Scripts;D:\Python34

(4)

命令行输入:python

有反应表示成功

说明:matplotlib还没有匹配python3.5的版本,我的电脑为64位

0Python安装学习指南

软件包下载:

因为涉及到众多包的下载,以及其中的版本和电脑位数问题特介绍如下(

注意加粗的字体):

(1)

numpy

numpy-1.10.1 mkl-cp34-none-win_amd64.whl

(2)

matplotlib

matplotlib-1.4.3.win-amd64-py3.4b/matplotlib-1.4.3/windows/

(3)

依赖包:pyparsing、dateutil、scipy

声明:以上软件地址可自行搜索

附注:图一为matplotlib

、图二为numpy

下载界面的选择

软件包numpy的安装:

1

命令行输入【完整的路径=numpy

在你电脑的绝对路径】

pip

install

完整的路径\numpy

-1.10.1 mkl-cp34-none-win_amd64.

2

验证:python编辑下

python>>

from

numpy

import

*

安装matplotlib:

matplotlib-1.4.3.win-amd64-py3.4

因为下载的是exe文件,点击一路执行即可

依赖包的安装:

在命令行里逐行输入如下命令:软件包的绝对路径

1

pip

install

绝对路径\pyparsing-2.0.3-py3-none-any.whl

2

pip

install

绝对路径\python_dateutil-2.4.2-py2.py3-none-any.whl

3

pip

install

绝对路径\matplotlib依赖\scipy-0.16.0-cp34-none-win_amd64.whl

验证是否安装成功:

1

在python编辑状态下导入安装的包:

import

matplotlib

import

numpy

import

scipy

import

pyparsing

import

matplotlib.pyplot

as

plt

2

如果缺少six

在安装完毕scipy之后把../Python34/Lib/site-packages/scipy/lib中的six.py

six.pyc

six.pyo三个文件拷贝到.../Python34/Lib/site-packages

案例1:

import

matplotlib.pyplot

as

plt

x

=

[0,

1,

2,

3,

4,

5]

y

=

[0.1,

0.2,

0.2,

0.3,

0.2,

0.1]

y2

=

[0.2,

0.2,

0.3,

0.2,

0.3,

0]

plt.plot(x,

y,

'b',

x,

y2,

'g')

plt.show()

案例2:

import

matplotlib.pyplot

as

plt

import

math

x=[]

y=[]

num=0.0

while

num

<

math.pi

*

4:

y.append(math.sin(num))

x.append(num)

num

=

0.1

plt.plot(x,

y,

'b')

plt.show()

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()

怎么用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)

结果:

用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()

多上面代原理,具体己照着官方文档

判断某一个四位数是不是玫瑰花数(所谓

%%四叶玫瑰数是指四位数上的数字的四次方之于本身的数。

clear;clc

s=input('请输入一个四:');

while fix(s/1000)>9|fix(s/1000)==0

s=(input('您输入的不是一个四位数,请重新输入:'));

end

a=fix(s/1000);

b=fix(s/100)-a*10;

c=fix(s/10)-a*100-b*10;

d=s-a*1000-b*100-c*10;

if a^4 b^4 c^4 d^4==s

disp([num2str(s) '是四叶玫瑰数.' ])

else

disp([num2str(s) '不是四叶玫瑰数.' ])

end

版权声明:本站所有文章皆为原创,欢迎转载或转发,请保留网站地址和作者信息。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值