Python绘制奥运五环

绘制奥运五环主要涉及到Python中的turtle绘图库运用:

turtle.forward(distance)


向当前画笔方向移动distance像素长度


turtle.backward(distance)


向当前画笔相反方向移动distance像素长度


turtle.right(degree)


顺时针移动degree°


turtle.left(degree)


逆时针移动degree°


turtle.pendown()


移动时绘制图形,缺省时也为绘制


turtle.goto(x,y)


将画笔移动到坐标为x,y的位置


turtle.penup()


提起笔移动,不绘制图形,用于另起一个地方绘制


turtle.circle()


画圆,半径为正(负),表示圆心在画笔的左边(右边)画圆


setx( )


将当前x轴移动到指定位置


sety( )


将当前y轴移动到指定位置


setheading(angle)


设置当前朝向为angle角度


home()


设置当前画笔位置为原点,朝向东。


dot(r)


绘制一个指定直径和颜色的圆点

程序源代码为:import turtleturtle.width(10)turtle.color(‘black‘)turtle.circle(50)turtle.penup()turtle.goto(120,0)turtle.pendown()turtle.color(‘red‘)turtle.circle(50)turtle.penup()turtle.goto(240,0)turtle.pendown()turtle.color(‘blue‘)turtle.circle(50)turtle.penup()turtle.goto(60,-50)turtle.pendown()turtle.color(‘yellow‘)turtle.circle(50)turtle.penup()turtle.goto(180,-50)turtle.pendown()turtle.color(‘pink‘)turtle.circle(50)#Python绘制奥运五环

运行后,结果为:



原文地址:https://www.cnblogs.com/AhriLove-chen/p/10659976.html

时间: 2024-08-09 23:43:41

Python绘制奥运五环的相关文章

Python 学习记录----利用Python绘制奥运五环

1 import turtle #导入turtle模块 2 turtle.color("blue") #定义颜色 3 turtle.penup() #penup和pendown()设置画笔抬起或放下时是否绘制直线 4 turtle.goto(-110,-25) #初始位置以中心坐标为(0,0) 5 turtle.pendown() 6 turtle.circle(45) #绘制圆的半径 7 8 turtle.color("black") 9 turtle.penup

python 相关语法 图形绘制 奥运五环

1. 适当的空格 逻辑行首的空白表示逻辑表示层次关系 从而决定分组 语句从新行的第一列开始 风格统一 都用四个空格 不能随便加空格 奥运五环 #绘制奥运五环 import turtleturtle.width(10) turtle.color("blue")turtle.circle(50) turtle.penup()turtle.goto(120,0)turtle.pendown()turtle.color("black")turtle.circle(50) t

利用Python 调用turtle函数库 绘制奥运五环。

import turtle #调用turtle库绘制图像的函数库turtle.color("blue") #颜色 蓝色turtle.circle(100) #画半径100的圆 turtle.penup() #抬起笔turtle.goto(-180,0) #移动到turtle.pendown() #放笔turtle.color("red") #颜色 红色turtle.circle(100) #画半径100的圆 turtle.penup() #提起笔turtle.got

turtle库绘制奥运五环

点击查看视频 import turtle turtle.pensize(10) turtle.color("blue") #定义颜色 turtle.penup() #penup和pendown()设置画笔抬起或放下时是否绘制直线 turtle.goto(-110,-25) #初始位置以中心坐标为(0,0) turtle.pendown() turtle.circle(45) #绘制圆的半径 turtle.pensize(10) turtle.color("black"

绘制奥运大五环

绘制奥运五环 # 绘制奥运五环 import turtle turtle.width(10) turtle.color("blue") turtle.circle(50) turtle.penup() turtle.goto(120,0) turtle.pendown() turtle.color("black") turtle.circle(50) turtle.penup() turtle.goto(240,0) turtle.pendown() turtle.

使用python绘制词云

最近在忙考试的事情,没什么时间敲代码,一个月也没几天看代码,最近看到可视化的词云,看到网上也很多这样的工具, 但是都不怎么完美,有些不支持中文,有的中文词频统计得莫名其妙.有的不支持自定义形状.所有的都不能自定义颜色 于是网上找了一下,决定用python绘制词云,主要用到的是wordcloud库,安装只需要pip isntall wordcloud就行, 数据用的是酒店评论的数据,代码如下: # -*- coding: utf-8 -*- import matplotlib.pyplot as

Div+Css(1):Div+Css中transparent制作奥运五环

<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>奥运五环</title> <style type="text/css"> body{ margin: 20px; background-color: #efefef; } ul.flag{ list-style: none;

Python绘制PDF文件~超简单的小程序

Python绘制PDF文件 项目简介 这次项目很简单,本次项目课,代码不超过40行,主要是使用 urllib和reportlab模块,来生成一个pdf文件. reportlab官方文档 http://www.reportlab.com/docs/reportlab-userguide.pdf 我们看看这个网页上的原数据: http://www.swpc.noaa.gov/ftpdir/weekly/Predict.txt 代码: #-*- coding: utf-8 -*- # 1. 用于下载原

使用python绘制常用的图表

使用python绘制常用的图表 本文介绍如果使用python汇总常用的图表,与Excel的点选操作相比,用python绘制图表显得比较比较繁琐,尤其提现在对原始数据的处理上.但两者在绘制图表过程中的思路大致相同,Excel中能完成的工作python大多也能做到.为了更清晰的说明使用python绘制图表的过程,我们在汇总图表的代码中进行注解,说明每一行代码的具体作用.并在文章的最后给出了自定义字体和图表配色的对应表. 准备工作 ? 1 2 3 4 5 import numpy as np impo