题目
题目
单项选择题

Question at position 14 A function named get_change has already been defined in the program. The function has the following signature: get_change(item_name: str, amount_paid: float) -> float If the missing lines are filled in correctly, the program should ask the user for the item name and the customer’s amount_paid, then uses the get_change function to calculate how much change to return to the customer. Finally, it should display the change formatted to two decimal places. [table] # get_price defined above5 def main():6 name = input('Enter the item name: ')7 paid = input('Enter the amount the customer paid: ')8 # ( code WILL go here )9 print(f'You will receive {result:.2f} change.')10 11 main() [/table] Which of the following options is the correct missing code? 8 result = get_change(name, paid)8 get_change(name, float(paid), result)8 result = get_change(item_name, amount_paid)8 result = get_change(name, float(paid))Clear my selection

选项
A.8     result = get_change(name, paid)
B.8     get_change(name, float(paid), result)
C.8     result = get_change(item_name, amount_paid)
D.8     result = get_change(name, float(paid))
查看解析

查看解析

标准答案
Please login to view
思路分析
The question describes a small program flow where we collect two inputs from the user and then call get_change to compute the change, finally printing it with two decimal places. Option A: 'result = get_change(name, paid)'. Here, paid is the raw string returned by input. Since get_change expects amount_paid to be a float, passing a string could cause a type error......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!