第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

Python 練習(xí)題(二)--畫出你的想象

標(biāo)簽:
Java Html/CSS Python
题目

内容:使用 turtle 画出你想象。

效果演示:
draw_name.gif

mindstorms.gif

我的解法
import turtle

#def draw_name():

def draw_h(pen):
    pen.down()
    pen.right(90)
    pen.forward(100)
    pen.backward(50)
    pen.left(90)
    pen.forward(50)
    pen.right(90)
    pen.forward(50)
    pen.backward(100)
    pen.left(90)

def draw_j(pen):
    pen.up()
    pen.forward(25)
    pen.down()
    pen.forward(50)
    pen.backward(25)
    pen.right(90)
    pen.forward(100)
    pen.right(90)
    pen.forward(25)
    pen.right(90)
    pen.forward(25)
    pen.right(90)

def draw_y(pen):
    x = pen.xcor()
    y = pen.ycor()
    pen.goto(x+25,y-50)
    pen.goto(x+50,y)
    pen.goto(x+25,y-50)
    pen.right(90)
    pen.forward(50)
    pen.left(90)

def draw_flower(pen):
    for i in range(0,36):
        for i in range(0,2):
            pen.forward(50)
            pen.right(60)
            pen.forward(50)
            pen.right(120)
        pen.right(10)
    pen.right(90)
    pen.forward(200)

def draw_art():
    pen = turtle.Turtle()
    pen.color("yellow")
    pen.shape("turtle")
    pen.speed(8)
    window = turtle.Screen()
    window.bgcolor("red")   
    draw_h(pen)
    pen.up()
    pen.forward(10)
    draw_j(pen)
    pen.up()
    pen.goto(170,0)
    pen.down()
    draw_y(pen)
    pen.up()
    pen.goto(-100,100)
    pen.down()
    draw_flower(pen)
    window.exitonclick()
draw_art()
import turtle

def draw_circle(angie): 
    angie.circle(50)

def draw_triangle(triangle):
    for y in range(0,3):
        triangle.forward(100)
        triangle.right(120)

def draw_square(turtle):
    for i in range(0,4):
        turtle.forward(100)
        turtle.right(90)

def draw_art():
    window = turtle.Screen()
    window.bgcolor("red")
    brad = turtle.Turtle()
    brad.shape("turtle")
    brad.speed(15)

    # 循环方形
    for i in range(0,36):
        brad.color("pink")
        draw_triangle(brad)
        brad.color("blue")
        draw_circle(brad)
        brad.color("yellow")
        draw_square(brad)   
        brad.right(10)
    brad.right(90)
    brad.forward(200)

    window.exitonclick()

# 方形画圆
draw_art()
# 添加音乐
步骤
  1. 获取画布turtle.Screen(),设置背景色
  2. 获取画笔 turtle.Turtle(),设置画笔形状颜色速度等
  3. 画出想要的图案
源码地址

Python-Exercies

點(diǎn)擊查看更多內(nèi)容
7人點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消