第三天

作业

1.使用turtle库,绘制一个八边形。图形如下所示:

import turtle as x
x.setup(800,800)
x.pensize(15)
x.penup()
x.bk(100)
x.pendown()
x.goto(0,100)
x.goto(100,100)
x.goto(200,0)
x.goto(200,-100)
x.goto(100,-200)
x.goto(0,-200)
x.goto(-100,-100)
x.goto(-100,0)
x.done()

1740924-20190715191043196-805260324.png

2.使用turtle库,绘制一个八角图形。图形如下所示:

import turtle as x
x.setup(800,800)
x.penup()
x.goto(-100,-50)
x.pendown()
x.goto(100,-50)
x.goto(-50,100)
x.goto(-50,-100)
x.goto(100,50)
x.goto(-100,50)
x.goto(50,-100)
x.goto(50,100)
x.goto(-100,-50)
x.done()

1740924-20190715191025867-1239754028.png

3.简述import <模块名>/from <模块名> import */import <模块名> as <新模块名>三者的区别

import 调用模块 使用方法为:模块名.方法名()使用时需要加上模块名

from import * 调用方法 使用方法:方法名()使用时不需要加上模块名,但有可能造成冲突

import as 调用模块 使用方法:新模块名.方法名()使用时加上新模块名,简化了模块名并不会造成冲突

4.设计程序,要求:循环打印数列`1,3,5,...,99

for i in range(1,100,2):
    print(i)

5.使用turtle库,绘制一个自己喜欢的图形,并截图发到微信群中

1740924-20190715190403811-1491886419.png

import turtle

#鼻子
turtle.setup(1000,800)
turtle.screensize(bg='yellow')
turtle.penup()
turtle.seth(90)
turtle.fd(100)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('black')
turtle.seth(45)
turtle.fd(25)
turtle.seth(135)
turtle.circle(25, 95)
turtle.seth(315)
turtle.fd(25)
turtle.end_fill()

# 眼睛
turtle.penup()
turtle.seth(160)
turtle.fd(250)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('black')
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.circle(50, 60)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('white')
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.seth(-9.5)
turtle.fd(530)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('black')
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.circle(50, 230)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('white')
turtle.circle(20)
turtle.end_fill()

#腮
turtle.penup()
turtle.seth(195)
turtle.fd(600)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('red')
turtle.circle(70)
turtle.end_fill()
turtle.penup()
turtle.seth(-11)
turtle.fd(720)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('red')
turtle.circle(70)
turtle.end_fill()

#嘴巴
turtle.penup()
turtle.seth(135)
turtle.fd(250)
turtle.pendown()
turtle.seth(-300)
turtle.circle(30, -65)
turtle.begin_fill()
turtle.fillcolor('Firebrick')
turtle.seth(165)
turtle.fd(140)
turtle.seth(195)
turtle.fd(140)
turtle.seth(-360)
turtle.circle(30, -65)
turtle.penup()
turtle.seth(-60)
turtle.circle(30, 65)
turtle.pendown()
turtle.seth(-70)
turtle.fd(240)
turtle.circle(55, 140)
turtle.seth(70)
turtle.fd(240)
turtle.end_fill()
turtle.seth(-110)
turtle.fd(80)
turtle.begin_fill()
turtle.fillcolor('Firebrick')
turtle.seth(120)
turtle.circle(120, 123)
turtle.seth(-70)
turtle.fd(165)
turtle.circle(55, 140)
turtle.seth(72)
turtle.fd(165)
turtle.end_fill()

turtle.done()

转载于:https://www.cnblogs.com/xm-lucky/p/11190961.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值