python蟒蛇绘制思路

python蟒蛇绘制思路

  • 图像工具讲解
  • 圆的思路讲解
    • 测试圆的代码
    • 测试圆的方向代码(seth(-40))
  • 画个横坐标和纵坐标
  • 测试left和right方向,画个数字8
  • 画一条蟒蛇

图像工具讲解

python蟒蛇绘制思路_第1张图片

圆的思路讲解

1、调试思路去学习
2、画圆,调试半径,调试角度,调试方向
3、程序一运行,立马退出来(time.sleep())
4、圆的半径,正直:箭头的方向在圆心点的右侧;负值:箭头的方向在圆心点的左侧

测试圆的代码

import turtle
import time
turtle.pensize(25)
turtle.pencolor(“red”)
turtle.seth(-40)
for i in range(4):
turtle.circle(40,80)
time.sleep(2)
turtle.circle(-40,80)
time.sleep(2)

python蟒蛇绘制思路_第2张图片

测试圆的方向代码(seth(-40))

import turtle
import time
turtle.pensize(25)
turtle.pencolor(“red”)
turtle.seth(-40)
for i in range(4):
turtle.circle(40,80)
time.sleep(2)
turtle.circle(-40,80)
time.sleep(2)

画个横坐标和纵坐标

import turtle
import time
turtle.fd(400)
time.sleep(5)
turtle.fd(-200)
time.sleep(5)
turtle.seth(90)
time.sleep(5)
turtle.fd(200)
time.sleep(5)
turtle.fd(-400)
time.sleep(5)
turtle.fd(200)
time.sleep(5)
turtle.seth(0)
time.sleep(5)
turtle.seth(-30)
time.sleep(5)
turtle.fd(100)
time.sleep(5)

测试left和right方向,画个数字8

import turtle
import time
turtle.fd(100)
time.sleep(5)
turtle.left(90)
time.sleep(5)
turtle.fd(100)
time.sleep(5)
turtle.left(90)
time.sleep(5)
turtle.fd(100)
time.sleep(5)
turtle.left(90)
time.sleep(5)
turtle.fd(100)
time.sleep(5)
turtle.fd(-200)
time.sleep(5)
turtle.right(180)
time.sleep(5)
turtle.right(90)
time.sleep(5)
turtle.fd(100)
time.sleep(5)
turtle.right(90)
time.sleep(5)
turtle.fd(100)
time.sleep(5)

画一条蟒蛇

import turtle
import time
turtle.setup(650,350,200,200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor(“blue”)
turtle.seth(-40)
for i in range(4):
turtle.circle(40,80)
time.sleep(2)
turtle.circle(-40,80)
time.sleep(2)
turtle.circle(40,40)
turtle.fd(40)
time.sleep(5)
turtle.circle(16,180)
turtle.fd(40*2/3)
time.sleep(30)

你可能感兴趣的:(Python语言程序设计基础,python,pycharm,开发语言)