程式語言教學誌
首頁 書籍與課程 遊戲 App 教材目錄 如何自學 C C++ C# Java Python EPUB 舊站

Python 入門指南 5.0

exercise1510.py

電子書購買頁面
GooglePlay-Python入門指南
Readmoo-Python入門指南
樂天kobo-Python入門指南
線上課程購買頁面
Python 專案開發入門的十堂課

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 引入 Point 定義
from exercise1501 import Point
# 引入 Animal 定義
from exercise1502 import Animal

# 定義 Mouse
class Mouse(Animal):
    def __init__(self, p, c):
        super().__init__(p, "鼠", c)
        self.food = ["鼠", "象"]

# 建立 Mouse 物件
mouse = Mouse(Point(3,3), "Blue")
# 印出鼠所在座標
print("動物" + mouse.name + "在" + str(mouse.point))
# 印出鼠可以吃掉的棋子種類
print("動物" + mouse.name + "可以吃", end="")
for i in mouse.food:
    print(i, end="")
print()

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

如果覺得這篇文章不錯~~

回到練習題目
上一頁 exercise1509.py
回 Python 入門指南 5.0 首頁
下一頁 exercise1601.py
回 Python 教材首頁
回程式語言教材首頁
AM 8:40:33

Facebook Youtube GitHub 微博