第三天

作业

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

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

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库,绘制一个自己喜欢的图形,并截图发到微信群中

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()
posted @ 2019-07-15 19:37  xm_lucky  阅读(88)  评论(0编辑  收藏  举报