hackMd 使用教學
封面、首頁、目錄
筆記內頁
ch07_函式與模組
7.1 自訂函式
7.2 數值函式
7.3 字串函式
7.4 亂數模組
7.5 時間模組
hello, welcome !!!
hello, welcome !!!
50
30
(78.5, 31.400000000000002)
(186.17060000000004, 48.356)
攝氏溫度轉華氏溫度 <ctof>
學生分蘋果 <divmod>
總和及排序 <sorted>
檢查網址格式 <startswith>
以字串排版函式列印成績單 <just>
轉換日期格式 <replace>
擲骰子遊戲 <randint>
大樂透中獎號碼 <sample>
列印時間函式所有資訊 <localtime>
計算執行一百萬次整數運算的時間 <pcounter>
89.6
實作3:
以十二小時(上午、下午)顯示現在時刻。
實作4:
小華媽媽上菜市場買菜,找錢時她希望在1元、5元、10元、50元硬幣中找回最少的硬幣。小華就利用自訂函式幫媽媽寫了一個程式。
1A2B
函式1 : 數字相同+位置相同
函式2 : 數字相同 + 位置不同
歡迎來到英文單字練習!
定義: a round fruit with red or green skin and sweet flesh
請輸入單辭的拼寫: apple
正確!
定義: a domesticated mammal that is related to the wolves
請輸入單辭的拼寫: dog
正確!
定義: an electronic device for storing and processing data
請輸入單辭的拼寫: computer
正確!
定義: a large body of saltwater that covers most of the Earth's surface
請輸入單辭的拼寫: ocean
正確!
定義: a written or printed work consisting of pages glued or sewn together along one side and bound in covers
請輸入單辭的拼寫: book
正確!
定義: a large natural elevation of the earth's surface rising abruptly from the surrounding level
請輸入單辭的拼寫: mountain
正確!
練習結束。您的得分是 6/6。
請問 'banana' 的中文意思是?
請輸入中文意思: 香蕉
正確!加10分。
你的分數: 10 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'banana' 的中文意思是?
請輸入中文意思: 香蕉
正確!加10分。
你的分數: 20 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'cat' 的中文意思是?
請輸入中文意思: 貓
正確!加10分。
你的分數: 30 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'dog' 的中文意思是?
請輸入中文意思: 狗
正確!加10分。
你的分數: 40 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'dog' 的中文意思是?
請輸入中文意思: 狗
正確!加10分。
你的分數: 50 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'cat' 的中文意思是?
請輸入中文意思: 貓
正確!加10分。
你的分數: 60 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'cat' 的中文意思是?
請輸入中文意思: 貓
正確!加10分。
你的分數: 70 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'banana' 的中文意思是?
請輸入中文意思: 香蕉
正確!加10分。
你的分數: 80 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'cat' 的中文意思是?
請輸入中文意思: 貓
正確!加10分。
你的分數: 90 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續):
請問 'flower' 的中文意思是?
請輸入中文意思: 花
正確!加10分。
你的分數: 100 分
是否要繼續遊戲?(輸入 'quit' 退出遊戲,其他任意鍵繼續): quit
遊戲結束,你的最終分數是: 100
函式的傳回值,下列何者正確?
(A)無傳回值 (B) 1 個傳回值 (C) 2 個傳回值 (D)以上皆可
Ans:( D )
print(max([4,8,3,9,2,6])) 顯示的結果為何?
(A)4 (B)6 (C)9 (D)2
Ans:( C )
print(pow(2,5,7)) 顯示的結果為何?
(A)2 (B)4 (C)5 (D)7
Ans:( B )
print("hospital".replace("s","t")) 顯示的結果為何?
(A)hotpital (B)hospisal (C)hospital (D)hotpisal
Ans:( A )
print("hospital".startswith("ho")) 顯示的結果為何?
(A)True (B)False (C)hospital (D)ho
Ans:( A )
print("hospital".find("p")) 顯示的結果為何?
(A)-1 (B)0 (C)3 (D)4
Ans:( C )
下列何者不可能是 print(random.randint(1,10)) 的顯示結果?
(A)0 (B)5 (C)8 (D)10
Ans:( A )
下列何者不可能是 print(random.randrange(0,15,3)) 的顯示結果?
(A)0 (B)3 (C)12 (D)15
Ans:( D )
下列哪一個函式可讓程式停止執行一段時間?
(A)time (B)sleep (C) perf_counter (D)localtime
Ans:( B )
localtime 傳回的 tm_min 資料範圍為何?
(A)1到60 (B)0到60 (C)0到59 (D)1到59
Ans:( C )
9
4
hotpital
True
3