開始使用免費開始

每月支出與儲蓄

為了在紐約市安頓下來,你決定和一位朋友合租一間兩房公寓。你需要為房租、餐飲和娛樂編列預算,同時每月也最好撥一筆「意外支出」的預備金。這筆預算可能用在各種事項,從添購衣物或電子產品,到看醫生預約都算在內。

請依下列項目設定你的每月預算:

  • 房租:$1200/月(含水電瓦斯等公用事業)
  • 餐飲:$30/日(平均值,含採買食材與外食)
  • 娛樂:$200/月(電影、飲料、博物館、派對等)
  • 意外支出:250/月(注意安全,別摔到你的手機!)

在本應用中,假設每個月平均為 30 天。支付完每月開支後所剩的金額,每月都會存入你的儲蓄帳戶。

上一個練習中的 monthly_takehome_salary 可供使用。

本練習屬於課程

Python 金融概念入門

檢視課程

練習說明

  • 計算你的每月總開支。
  • 計算你的每月儲蓄(也就是支付完每月開支後所剩的金額)。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Enter your monthly rent
monthly_rent = ____

# Enter your daily food budget
daily_food_budget = ____

# Calculate your monthly food budget assuming 30 days per month
monthly_food_budget = ____

# Set your monthly entertainment budget
monthly_entertainment_budget = ____

# Allocate funds for unforeseen expenses, just in case
monthly_unforeseen_expenses = ____

# Next, calculate your total monthly expenses
monthly_expenses = ____
print("Monthly expenses: " + str(round(monthly_expenses, 2)))

# Finally, calculate your monthly take-home savings
monthly_savings = monthly_takehome_salary - ____
print("Monthly savings: " + str(round(monthly_savings, 2)))
編輯並執行程式碼