# 購買機器寵物
def robot_pet_store(category, color, pet_type=None):
"輸出機器寵物資訊"
category_dict = {"dog":"狗", "cat":"貓", "bird":"鳥"}
color_dict = {"black":"黑", "white":"白", "red":"紅", "yellow":"黃"}
pet_type_dict = {"home":"居家型", "race":"競賽型"}
category = category_dict[category]
color = color_dict[color]
print(f"你選的是機器{category}")
if pet_type == None:
print(f"你選的機器{category}是{color}色的")
else:
pet_type = pet_type_dict[pet_type]
print(f"你選的機器{category}是{color}色的{pet_type}")
# 傳遞輸入參數
category = input("輸入機器寵物種類英文代碼: dog(狗) cat(貓) bird(鳥) > ")
color = input("輸入顏色代碼: black(黑) white(白) red(紅) yellow(黃) > ")
if category == "dog" or category == "cat":
pet_type = input("輸入型別代碼: home(居家型) race(競賽型) > ")
robot_pet_store(category, color, pet_type)
else:
robot_pet_store(category, color)
# 傳遞固定參數
robot_pet_store(pet_type="home", color="black", category="cat")
robot_pet_store("bird", color="white")
"""
# 針對下列敘述,正確的選 Yes,否則選 No
A. robot_pet_store() 函式有回傳值
B. robot_pet_store(category, color, pet_type) 呼叫無效
C. robot_pet_store(category, color) 呼叫有錯
D. robot_pet_store(pet_type="home", color="black", category="cat") 呼叫無效
E. robot_pet_store("bird", color="white") 呼叫有錯
"""