## wk11_1116_module_實戰
### 【inclass practice】
{綜合演練}
實作3:
以十二小時(上午、下午)顯示現在時刻。
實作4:
小華媽媽上菜市場買菜,找錢時她希望在1元、5元、10元、50元硬幣中找回最少的硬幣。小華就利用自訂函式幫媽媽寫了一個程式。
{範例}
攝氏溫度轉華氏溫度 \
學生分蘋果 \
總和及排序 \
檢查網址格式 \
以字串排版函式列印成績單 \
轉換日期格式 \
擲骰子遊戲 \
大樂透中獎號碼 \
列印時間函式所有資訊 \
計算執行一百萬次整數運算的時間 \
```python
import time
print("hello")
time.sleep(1)
print("winnie")
```
hello
winnie
```python
import time as t
print("hello")
t.sleep(1)
print("winnie")
```
hello
winnie
```python
from time import sleep, perf_counter
print("hello")
sleep(1)
print("winnie")
```
hello
winnie
```python
for i in range(11):
print(i)
sleep(1)
```
0
1
2
3
4
5
6
7
8
9
10
```python
startTime = perf_counter()
for i in range(3):
print(i)
sleep(0.97)
endTime = perf_counter()
print(f"總費時:{endTime-startTime}秒")
```
0
1
2
總費時:2.916545000000042秒
```python
t.localtime()
```
time.struct_time(tm_year=2023, tm_mon=11, tm_mday=20, tm_hour=10, tm_min=1, tm_sec=10, tm_wday=0, tm_yday=324, tm_isdst=0)
```python
t.ctime()
```
'Mon Nov 20 10:01:51 2023'
```python
import random as r
while True:
inKey = input("按任意鍵 然後enter鍵, 擲骰子; 若要結束遊戲, 請直接按enter")
if len(inKey) >0:
print(r.randint(1,6))
else:
print("game over")
break
```
按任意鍵 然後enter鍵, 擲骰子; 若要結束遊戲, 請直接按enter
5
按任意鍵 然後enter鍵, 擲骰子; 若要結束遊戲, 請直接按enter
4
按任意鍵 然後enter鍵, 擲骰子; 若要結束遊戲, 請直接按enter
1
按任意鍵 然後enter鍵, 擲骰子; 若要結束遊戲, 請直接按enter
game over
### 【afterclass practice】
1. 教學影音:
- 新手入門 #07 Function (函式)
- 新手入門 #09 Module (模組)
2. 期末分組名單