首页 > 其他分享 >实验六

实验六

时间:2023-06-06 16:33:48浏览次数:35  
标签:draw move range 实验 import def size

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

 

task2_1

from turtle import *
def move(x,y):
    penup()
    goto(x,y)
    pendown()
def main():
    setup(800,600)
    radius=20
    offset=20
    for i in range(9):
        move(0,-radius)
        circle(radius)
        radius+=offset
    hideturtle()
    done()
main()

 

task2_2

from turtle import *
from random import random
def move(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):
        move(0,-radius)
        color(gen_color())
        begin_fill()
        circle(radius)
        end_fill()
        radius-=offset
    hideturtle()
    done()
main()

 

task3_1

from turtle import *
def square(size=50,rgb='pink'):
    pencolor(rgb)
    for i in range(4):
        fd(size)
        left(90)
def main():
    setup(800,600)
    speed(0)
    n=10
    for i in range(n):
        square(80,'orange')
        left(360/n)
    hideturtle()
    done()
main()

 

task3_2

from turtle import *
setup(800,600)
pencolor('pink')
n=10
speed(0)
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(1600,1200)
bgcolor('black')
pencolor('white')
speed(0)
angle=0
size=1
n=5
count=100
for i in range(count):
    fd(size)
    angle+=360/n
    seth(angle)
    size+=5
hideturtle()
done()

 

task5_1

from turtle import *
def move(x,y):
    penup()
    goto(x,y)
    pendown()
def draw(n,c,size = 100):
    color(c)
    begin_fill()
    for i in range(n):
        fd(size)
        left(360/n)
    end_fill()
move(-100,-100)
draw(4,'black',200)
move(-100,0)
right(45)
draw(4,'red',100*(2)**0.5)
hideturtle()
done()

 

task5_2

from turtle import *
pensize(2)
def move(x,y):
    penup()
    goto(x,y)
    pendown()
def quarter_round(r):
    pencolor('blue')
    move(0,r)
    circle(-r,90)
    for i in range(2):
        right(90)
        fd(r)
    home()

radius=40
offset=20
for i in range(5):
    quarter_round(radius)
    radius+=offset
hideturtle()
done()

 

task6

from turtle import *
speed(0)
def move(x,y):
    penup()
    goto(x,y)
    pendown()
bgcolor('black')
color('yellow')
move(0,-100)
begin_fill()
circle(100)
end_fill()
color('black')
move(87,-51)
seth(60)
begin_fill()
circle(100,60)
home()
end_fill()
move(-30,50)
dot(30,'black')
move(-38,58)
dot(5,'white')
hideturtle()
done()

 

标签:draw,move,range,实验,import,def,size
From: https://www.cnblogs.com/fyx1978501071/p/17460931.html

相关文章

  • 实验5
    task6withopen('data6.csv','r',encoding='gbk')asf:data=list(f.readlines())data=[i.strip('\n')foriindata]importdecimaldecimal.getcontext().rounding='ROUND_HALF_UP'title=[data[0],'四......
  • 《大学物理实验上》期末笔记(一)不确定度的计算
    《大学物理实验上》期末笔记(一)不确定度的计算什么是不确定度?​ ★不确定度表示测量值可能变动(不能确定)的范围,也是与测量结果相关的一个参数,用于合理表示由于测量误差的存在而对被测量值的不能肯定的程度。​ 简单来说,我们测得一组值,分别为\(x_1,x_2,x_3...x_n\),我们可以通过......
  • 经纬恒润整车在环测试实验室发布新技术特性
        作为国内最早开展整车在环仿真测试技术预研的企业之一,经纬恒润自2016年起,正式启动了整车在环仿真相关技术的预研工作。整车在环实现了从半实物仿真到机械混合仿真的跨步,将功能测试与性能测试打包整合,从整车完整的功能和机械表现,评价了车辆整体能力。近年来,伴随着汽车行......
  • 2023年5月31日吴曦远202283820011实验五
    task1_1.pycode:withopen('data1.txt','r',encoding='utf-8')asf:data=f.readlines()n=0print(data)forlineindata:ifnotline.strip()=='':n+=1print(n)output:note:ifdelet"not"......
  • 实验5
    实验任务6withopen('C:/Users/Lenovo/Desktop/data6.csv','r',encoding='gbk')asf:data1=f.read().split('\n')deldata1[0]foriinrange(len(data1)):data1[i]=eval(data1[i])data1[i]=float(data1[i])p......
  • 实验6 turtle绘图和Python库应用编程体验
    实验任务1task1_1.py源代码1fromturtleimport*23defmove(x,y):4penup()5goto(x,y)6pendown()78defdraw(n,size=100):9foriinrange(n):10fd(size)11left(360/n)1213defmain():14pensize(2)1......
  • 实验5
     with open('data6.csv','r',encoding='gbk') as f:  data1 = f.read().split('\n')del data1[0]print('原始数据:')print(data1)for i in range(len(data1)):    data1[i] = float(data1[i])data2 = []for i in ra......
  • 实验6 turtle绘图与python库应用编程体验
    实验任务1task1_11fromturtleimport*23defmoveto(x,y):4'''5画笔移动到坐标(x,y)处6'''7penup()8goto(x,y)9pendown()1011defdraw(n,size=100):12'''13绘制边长为s......
  • 实验五 文件应用编程
    实验任务61#读取并处理原始数据withopen('data6.csv','r',encoding='gbk')asf:2old_data=f.read().split('\n')3delold_data[0]4#四舍五入得到新数据5new_data=[]6foriinrange(len(old_data)):7ifeval(ol......
  • 实验5 文件应用编程
    实验任务61withopen('data6.csv','r',encoding='gbk')asf:2old_data=f.read().split('\n')3delold_data[0]45new_data=[]6foriinrange(len(old_data)):7ifeval(old_data[i])+float(0.5)......