python绘制哆啦a梦实训报告,python画图哆啦a梦-python 绘制哆啦A梦

【实例简介】 绘制哆啦A梦

【实例截图】

7f1054644144496ff27c448783198495.png

【核心代码】

#!/usr/bin/python

# -*- coding: UTF-8 -*-

# 哆啦A梦

import turtle

def flyTo(x, y):

turtle.penup()

turtle.goto(x, y)

turtle.pendown()

def drawEye():

turtle.tracer(False)

a = 2.5

for i in range(120):

if 0 <= i < 30 or 60 <= i < 90:

a -= 0.05

else:

a = 0.05

turtle.left(3)

turtle.fd(a)

turtle.tracer(True)

def beard():

""" 画胡子, 一共六根

"""

# 左边第一根胡子

flyTo(-37, 135)

turtle.seth(165)

turtle.fd(60)

# 左边第二根胡子

flyTo(-37, 125)

turtle.seth(180)

turtle.fd(60)

# 左边第三根胡子

flyTo(-37, 115)

turtle.seth(193)

turtle.fd(60)

# 右边第一根胡子

flyTo(37, 135)

turtle.seth(15)

turtle.fd(60)

# 右边第二根胡子

flyTo(37, 125)

turtle.seth(0)

turtle.fd(60)

# 右边第三根胡子

flyTo(37, 115)

turtle.seth(-13)

turtle.fd(60)

def drawRedScarf():

""" 画围巾

"""

turtle.fillcolor("red") # 填

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Python绘制哆啦A梦,可以使用Python的turtle库。下面是一个简单的例子: ```python import turtle # 设置画笔 t = turtle.Pen() t.speed(0) t.pensize(3) # 绘制哆啦A梦的头部 t.color('blue', 'blue') t.begin_fill() t.circle(100) t.end_fill() # 绘制哆啦A梦的耳朵 t.penup() t.goto(50, 180) t.pendown() t.color('white', 'white') t.begin_fill() t.circle(30) t.end_fill() t.penup() t.goto(-50, 180) t.pendown() t.begin_fill() t.circle(30) t.end_fill() # 绘制哆啦A梦的眼睛 t.penup() t.goto(-30, 50) t.pendown() t.color('white', 'white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(30, 50) t.pendown() t.color('white', 'white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(-20, 60) t.pendown() t.color('black', 'black') t.begin_fill() t.circle(10) t.end_fill() t.penup() t.goto(40, 60) t.pendown() t.color('black', 'black') t.begin_fill() t.circle(10) t.end_fill() # 绘制哆啦A梦的鼻子 t.penup() t.goto(0, 20) t.pendown() t.color('pink', 'pink') t.begin_fill() t.circle(10) t.end_fill() # 绘制哆啦A梦的嘴巴 t.penup() t.goto(-50, -20) t.pendown() t.color('black', 'black') t.goto(50, -20) t.goto(50, -40) t.goto(-50, -40) t.goto(-50, -20) # 绘制哆啦A梦的身体 t.penup() t.goto(-100, -100) t.pendown() t.color('blue', 'blue') t.begin_fill() for i in range(2): t.forward(200) t.circle(50, 180) t.end_fill() # 绘制哆啦A梦的手和脚 t.penup() t.goto(-100, -150) t.pendown() t.color('white', 'white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(100, -150) t.pendown() t.color('white', 'white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(-100, -200) t.pendown() t.color('white', 'white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(100, -200) t.pendown() t.color('white', 'white') t.begin_fill() t.circle(20) t.end_fill() # 隐藏画笔 t.hideturtle() # 等待窗口关闭 turtle.done() ``` 运行上述代码,将会绘制出一个哆啦A梦的图像。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值