AU Fundamentals of Python Programming

Ex7-1(練習7-1):M1-Q20 找零錢問題

假設銅板有1元、5元、50元共三種,媽媽請小明去菜市場買水果,給了小明 n 元,且媽媽交待,要老闆找小明的零錢的數目要最少,而小明到了水果攤買了 a_1顆蘋果,a_2顆柳丁,及 a_3 顆桃子,1顆蘋果15元,1顆柳丁20元,1顆桃子30元,請問老問需找多少個1元、5元、50元,其銅板數目最少。

Step 1: 先輸入媽媽給小明多少錢 n

n=int(input())
---------------------------------------------------------------------------
StdinNotImplementedError                  Traceback (most recent call last)
/tmp/ipykernel_901/1095811832.py in <module>
----> 1 n=int(input())

~/.local/lib/python3.8/site-packages/ipykernel/kernelbase.py in raw_input(self, prompt)
   1001         """
   1002         if not self._allow_stdin:
-> 1003             raise StdinNotImplementedError(
   1004                 "raw_input was called, but this frontend does not support input requests."
   1005             )

StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.

Step 2: 輸入 a_1顆蘋果,a_2顆柳丁,及 a_3 顆桃子

Step 3: 計算金額及剩下的錢

Step 4: 計算銅板數目

Ex7-2(練習7-2):M1-Q32 數字價格轉文字價格

輸入一 1~1000 的價格,並跟據此價格在螢幕上印出「? thousand ? hundred? ten? dollar字樣。

Enter a price ranging from 1 to 1000, and print “? One thousand? Hundred? Ten? Dollar?” based on the price.

Step 5: 輸入一 1~1000 的價格

Step 6: 計算百位、十位及個位數

Step 7: 列印結果