MulaiMulai sekarang secara gratis

Monthly expenses and savings

In order to make it in New York City, you have decided to split a two-bedroom apartment with a friend. You will have to budget for rent, food and entertainment, but it's also a good idea to allocate an amount for unforeseen expenses each month. This unforeseen expenses budget could be used for anything ranging from new clothes or electronics to doctor appointments.

Set up your monthly budget as follows:

  • Rent: $1200 / month (Includes utilities)
  • Food: $30 / day (On average. Includes groceries and eating out.)
  • Entertainment: $200 / month (Movies, drinks, museums, parties…)
  • Unforeseen Expenses: 250 / month (Stay safe, and don't drop your phone!)

For this application, assume an average of 30 days per month. Whatever is left after your paying your monthly expenses will go into your savings account each month.

monthly_takehome_salary from the previous exercise is available.

Latihan ini adalah bagian dari kursus

Introduction to Financial Concepts in Python

Lihat Kursus

Petunjuk latihan

  • Calculate your monthly expenses.
  • Calculate your monthly savings (what's left after paying your monthly expenses).

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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)))
Edit dan Jalankan Kode