Python 入門指南 5.0

exercise1902.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 計數的全域變數
count = 1

# 印出全域變數
def print_count():
    print(count)

# 遞增計數的全域變數
def add_count():
    global count
    count += 1

# 執行部分
if __name__ == "__main__":
    print_count()
    add_count()
    print_count()

# 檔名: exercise1902.py
# 說明:《Python入門指南》的練習
# 網站: http://kaiching.org
# 作者: 張凱慶
# 時間: 2023 年 10 月

回到練習題目
上一頁 exercise1901.py
回 Python 入門指南 5.0 首頁
下一頁 exercise1903.py
回 Python 教材首頁
回程式語言教材首頁