zoukankan      html  css  js  c++  java
  • 第二次作业

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


    import turtle as t

    t.setup(400,400)
    t.pensize(4)
    t.pencolor('black')
    t.penup()
    t.goto(-80,150)
    t.pendown()
    t.fd(80)
    for i in range(7):
     t.right(45)
     t.fd(80)

    t.done()

     

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

      import turtle as t

      t.setup(400,400)
      t.pensize(4)
      t.pencolor('black')
      t.penup()
      t.goto(-150,-50)
      t.pendown()
      t.fd(200)
      for i in range(7):
        t.left(135)
        t.fd(200)

      t.done()

       

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

      使用import <模块名>,在调用的时候需要先写文件名称

      使用from <模块名> import *,导入该模块所有函数方法,则不需要使用据点,只要调用他的名称就可以

      使用import <模块名> as <新模块名>:

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

      for i in range(1,101):    if i % 2 == 1:        print(i)

    3. 使用turtle库,绘制一个自己喜欢的图形,并截图发到微信群中,别告诉我你喜欢一条直线(/哭笑),如下图:

      import turtle as t

      t.setup(400,650)
      t.pensize(1)
      t.pencolor('black')
      #左角
      t.penup()
      t.goto(-150,300)
      t.pendown()
      t.seth(180)
      t.circle(5,180)
      t.circle(-18,80)
      t.penup()
      t.goto(-150,300)
      t.seth(25)
      t.pendown()
      t.circle(-30,100)
      # 头
      t.seth(105)
      t.circle(-10,180)
      t.seth(115)
      t.circle(-12,190)
      t.seth(105)
      t.circle(-10,190)
      t.seth(90)
      t.circle(-10,190)
      t.seth(80)
      t.circle(-10,180)
      t.seth(75)
      t.circle(-10,180)
      t.seth(70)
      t.circle(-10,180)
      #右角

      t.seth(70)
      t.circle(-28,80)
      t.circle(-5,180)
      t.seth(200)
      t.circle(25,60)
      # 头
      t.seth(10)
      t.circle(-10,180)
      t.seth(8)
      t.circle(-10,180)
      t.seth(6)
      t.circle(-10,180)
      t.seth(0)
      t.circle(-10,180)
      t.seth(-10)
      t.circle(-10,180)
      t.seth(-20)
      t.circle(-10,180)
      t.seth(-30)
      t.circle(-10,180)
      t.seth(-180)
      t.circle(-8,200)
      for i in range(2):
       t.seth(-200)
       t.circle(-14,140)
      t.seth(-170)
      t.circle(-14,140)
      t.seth(-160)
      t.circle(-14,140)
      t.seth(-150)
      t.circle(-14,140)
      t.seth(-100)
      t.circle(-14,140)
      t.seth(-110)
      t.circle(-14,140)
      t.seth(-100)
      t.circle(-14,140)
      t.seth(-80)
      t.circle(-14,140)
      t.seth(-55)
      t.circle(-14,130)
      t.seth(-25)
      t.circle(-14,140)
      t.seth(-25)
      t.circle(-14,140)
      t.seth(-5)
      t.circle(-14,140)
      t.seth(-90)
      t.circle(-8,170)
      t.seth(180)
      t.circle(-10,180)
      t.seth(180)
      t.circle(-10,180)
      t.seth(190)
      t.circle(-10,180)
      t.seth(190)
      t.circle(-10,180)
      t.seth(210)
      t.circle(-10,180)
      t.seth(140)
      t.circle(-10,180)
      t.seth(140)
      t.circle(-10,180)
      t.seth(140)
      t.circle(-10,160)
      #眼睛
      t.penup()
      t.goto(-90,200)
      t.seth(-90)
      t.pensize(2)
      t.pendown()
      t.circle(-10,360)
      t.pensize(5)
      t.circle(-4,360)

      t.penup()
      t.goto(10,200)
      t.seth(-90)
      t.pensize(2)
      t.pendown()
      t.circle(-10,360)
      t.pensize(5)
      t.circle(-4,360)
      #鼻子
      t.penup()
      t.goto(-50,170)
      t.pensize(5)
      t.pendown()
      t.circle(-4,360)
      #下巴
      t.penup()
      t.goto(-130,140)
      t.pensize(1)
      t.pendown()
      t.seth(-45)
      t.circle(120,85)
      #嘴
      t.penup()
      t.goto(-80,140)
      t.pensize(2)
      t.pendown()
      t.seth(-25)
      t.circle(50,50)
      t.pencolor('white')


      t.done()

       

     

  • 相关阅读:
    (C#) 设定时间格式
    (WPF) MVVM: 动态添加控件及绑定。
    (WPF) MVVM: DataGrid Binding
    (WPF) MVVM: ComboBox Binding, XML 序列化
    (C#) 判断相等?
    ASP.NET MVC过滤器中权限过滤器ValidateAntiForgeryToken的用法(Post-Only)
    根据2个经纬度点,计算这2个经纬度点之间的距离
    ASP.NET导出Excel(利用NPOI和EPPlus库,无需安装Office)
    nopcommerce 二次开发
    SQL效率低下原因主要有
  • 原文地址:https://www.cnblogs.com/hanyi12/p/11190742.html
Copyright © 2011-2022 走看看