harry 學習python的函式用法

2021-09-29 14:08:20 字數 2110 閱讀 4057

# 函式:商店老闆、

# 教def

landlord()

:print

("懶得勞動"

)print

("不想勞動"

)print

("不想勞"

)print

("不想"

)print

("不"

)# 叫

landlord(

)import turtle

import random

defll()

: turtle.fd(

100)

turtle.lt(

144)

turtle.fd(

100)

turtle.lt(

144)

turtle.fd(

100)

turtle.lt(

144)

turtle.fd(

100)

turtle.lt(

144)

turtle.fd(

100)

turtle.lt(

144)

defgoto()

: turtle.up(

) turtle.goto(random.randint(

-350

,350

), random.randint(

-350

,350))

turtle.down(

)ll(

)goto(

)ll(

)turtle.done(

)

import turtle

import random

defll()

:for a in

range(5

):turtle.fd(

100)

turtle.lt(

144)

defgoto()

: turtle.up(

) turtle.goto(random.randint(

-350

,350

), random.randint(

-350

,350))

turtle.down(

)# 重複執行相同的** 迴圈的東西

# for迴圈 whilel()

for a in

range

(100):

ll() goto(

)turtle.done(

)

import turtle

import random

defll

(length,angle,count)

:for a in

range

(count)

: turtle.fd(length)

turtle.lt(angle)

defgoto()

: turtle.up(

) turtle.goto(random.randint(

-350

,350

), random.randint(

-350

,350))

turtle.down(

)# 重複執行相同的** 迴圈的東西

# for迴圈 while迴圈

turtle.speed(0)

turtle.bgcolor(

'black'

)for a in

range

(100):

turtle.color(random.random(

), random.random(

),random.random())

# 三原色(顏料)和三基色(光) red green blue# 三種顏色深度0-1

goto(

) ll(random.randint(1,

100)

,250,10

)turtle.done(

)

Python 學習筆記 enumerate函式

enumerate 函式用於將乙個可遍歷的資料物件 如列表 元組或字串 組合為乙個索引序列,同時列出資料和資料下標,一般用在 for 迴圈當中。seasons spring summer fall winter list enumerate seasons 0,spring 1,summer 2,f...

python函式學習內容 python的函式學習

函式和過程 過程就是沒有返回值的函式 兩者都能 呼叫 在python中,函式返回值為return後面的值,而過程返回值為none 程式設計方式 物件導向 面向過程 函式式程式設計 面向過程程式設計 就是通過乙個個def所定義的小過程而拼接到一塊 函式式程式設計 f 2x 數學上的函式 有乙個x,就會...

harry 學習知識問答題庫

import easygui import random easygui.msgbox 歡迎來到吃雞問答 name easygui.enterbox 請輸入您的名字 easygui.msgbox 你好 name s2 吃雞里哪個掛最強?a 隱身掛,b 追蹤子彈掛 哪個地方的物資最多?a 皮卡多 b ...