首页 > 其他分享 >实验六

实验六

时间:2023-06-12 14:56:20浏览次数:34  
标签:moveto hideturtle range done import 实验 def

task1-1

from turtle import *

def move(x, y):
    penup()
    goto(x, y)
    pendown()

def draw(n, size = 100):
    for i in range(n):
        fd(size)
        left(360/n)

def main():
    pensize(2)
    pencolor('red')

    move(-200,0)
    draw(3)

    move(0, 0)
    draw(4)

    move(200, 0)
    draw(5)

    hideturtle()
    done()


main()

截图

 task1-2

from turtle import *

def moveto(x, y):
    penup()
    goto(x, y)
    pendown()

def main():
    pensize(2)
    pencolor('blue')

    moveto(-150, 0)
    circle(50)

    moveto(0, 0)
    circle(50, steps = 4)

    moveto(150, 0)
    circle(50, steps = 5)

    moveto(300, 0)
    circle(50, steps = 6)


    hideturtle()
    done()

main()

截图

 task2-1

from turtle import *
def moveto(x, y):
    penup()
    goto(x, y)
    pendown()

def main():
    setup(800, 600)

    radius = 20
    offset = 20

    for i in range(9):
        moveto(0, -radius)
        circle(radius)
        radius += offset
    hideturtle()
    done()

main()

截图

 task2-2

from turtle import *
from random import random

def moveto(x, y):
    penup()
    goto(x, y)
    pendown()

def gen_color():
    return tuple((random() for i in range(3)))

def main():
    setup(800, 600)

    radius = 180
    offset = 20

    for i in range(8):
        moveto(0, -radius)
        color(gen_color())

        begin_fill()
        circle(radius)
        end_fill()

        radius -= offset

    hideturtle()
    done()

main()

截图

 task3

from turtle import *

def square(size = 50, rgb = 'orange'):

    pencolor(rgb)
    for i in range(4):
        fd(size)
        left(90)

def main():
    setup(800, 600)
    speed(0)

    n = 11
    for i in range(n):
        square(80)
        left(360/n)

    hideturtle()
    done()

main()

截图

 task3-2

from turtle import *

setup(800, 500)
pencolor('pink')

n = 10
for i in range(10):
    for j in range(2):
        circle(80, 90)
        left(90)

    right(360/n)

hideturtle()
done()

截图

 task4

from turtle import *

setup(800, 600)
bgcolor('black')
pencolor('white')
speed(0)

angle = 0
size = 2

n = 5
count = 50
for i in range(count):
    fd(size)
    angle += 360/n
    seth(angle)
    size += 5

hideturtle()
done()

截图

 task5-1

from turtle import *

def moveto(x, y):
    penup()
    goto(x, y)
    pendown()

pensize(3)
color('black')
begin_fill()
moveto(-100, -100)
for i in range(4):
    fd(200)
    left(360/4)
end_fill()

moveto(0, -100)
color('red')
begin_fill()
circle(100,steps = 4)
end_fill()


hideturtle()
done()

截图

 task5-2

from turtle import *
pensize(2)
pencolor('blue')
r = 40
for i in range(5):
    fd(r)
    left(90)
    circle(r,90)
    left(90)
    fd(r)
    left(90)
    r += 20

hideturtle()
done()

截图

 task6

moveto(200,-200)
color('yellow')
begin_fill()
left(135)
fd(200)
right(90)
fd(200)
left(90)
circle(200,270)
end_fill()

moveto(80,70)
dot(40,'black')
moveto(72,76)
dot(10,'white')

hideturtle()
done()

截图

 

标签:moveto,hideturtle,range,done,import,实验,def
From: https://www.cnblogs.com/melancholy-z/p/17475020.html

相关文章

  • 实验6
    实验任务1task1_1.py1fromturtleimport*2defmove(x,y):3'''画笔移动到坐标(x,y)处'''4penup()5goto(x,y)6pendown()78defdraw(n,size=100):9'''绘制边长为size的正n变形''&#......
  • 实验6 turtle绘图与python库应用编程体验
    实验任务1fromturtleimport*defmove(x,y):'''画笔移动到坐标(x,y)处'''penup()goto(x,y)pendown()defdraw(n,size=100):'''绘制边长为size的正n边形'''foriinrange(n):fd(siz......
  • Linux操作系统实训操作五(实验效果)
    Linux操作系统实训操作五(实验效果)原创 宇翔2020 网路小栈 2023-04-1007:00 发表于山东收录于合集#Linux操作系统2个#CentOS4个 1、新建用户jyzy(计应专业)、dmzy(动漫专业)、shzy(书画专业)、hkzy(航空专业),用tail命令查看/etc/passwd文件的后四行内容。(截图)。 ......
  • 实验六
    实验任务1task1.1实验源码1fromturtleimport*2defmove(x,y):3penup()4goto(x,y)5pendown()6defdraw(n,size=100):7foriinrange(n):8fd(size)9left(360/n)10defmain():11pensize(2)12p......
  • php文件上传之白名单00截断实验
    %00截断介绍:0x00,%00,/00在url中%00表示ascll码中的0,而ascii中0作为特殊字符保留,表示字符串结束,所以当url中出现%00时就会认为读取已结束。但是所谓的if拦截仍会读取后面的后缀达到绕过白名单的效果。当前版本环境:PHP版本低于5.4.24,或者PHP版本在5.5.8到5.6.0之间,且GPC......
  • 实验六
    实验任务一task1_1实验源码:1fromturtleimport*23defmove(x,y):4penup()5goto(x,y)6pendown()7defdraw(n,size=100):#绘制边长为size的正n边形8foriinrange(n):9fd(size)10left(360/n)11defmain():12......
  • Python实验课6
    实验任务一实验源码:fromturtleimport*defmove(x,y):penup()goto(x,y)pendown()defdraw(n,size=100):foriinrange(n):fd(size)left(360/n)defmain():pensize(2)pencolor('red')move(-200,0)......
  • 实验六
    实验1task1.1实验源码1fromturtleimport*23defmove(x,y):4penup()5goto(x,y)6pendown()78defdraw(n,size=100):9foriinrange(n):10fd(size)11left(360/n)1213defmain():14pensize(2)15......
  • 实验七
    任务一实验源码1classAccount:2'''一个模拟银行账户的简单类'''3def__init__(self,name,account_number,initial_amount=10):4'''构造新账户'''5self._name=name6self._c......
  • 实验六
    任务一实验源码1fromturtleimport*23defmove(x,y):4penup()5goto(x,y)6pendown()78defdraw(n,size=100):9foriinrange(n):10fd(size)11left(360/n)1213defmain():14pensize(2)15......