Get Started

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.

This is a part of the course

“Introduction to Financial Concepts in Python”

View Course

Exercise instructions

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

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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 and Run Code

This exercise is part of the course

Introduction to Financial Concepts in Python

BeginnerSkill Level
4.6+
8 reviews

Using Python and NumPy, learn the most fundamental financial concepts.

You just got a new job as a data scientist in San Francisco, and you're looking for an apartment. In this chapter, you'll be building your own budgeting application to plan out your financial future.

Exercise 1: Budgeting project proposalExercise 2: Salary and taxesExercise 3: Monthly expenses and savings
Exercise 4: Forecast salary growth and cost of livingExercise 5: Forecast growing expenses due to inflationExercise 6: Net worth and valuation in your personal financial lifeExercise 7: Calculate your net worthExercise 8: So you want to be a millionaire?Exercise 9: Investing a percentage of your income (I)Exercise 10: Investing a percentage of your income (II)Exercise 11: The power of time and compound interestExercise 12: Investing over timeExercise 13: Inflation-adjusted net worthExercise 14: Financial concepts in your daily life

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free