Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


Login

Start interactive tutorial

← Back to Projects

Monthly Sales Analyzer

Difficulty

  • easy

Technologies

Difficulty

  • easy

Technologies

📝 Instructions

🌱 How to start this project

Follow these instructions:

  1. Create a new repository by forking the Git project or clicking here.
  2. Open the newly created repository in Codespace using the Codespace button extension.
  3. Once the VSCode in Codespace has finished opening, start your project by following the instructions below.

📝 Instructions

You have been provided with a Python file (monthly_sales_analyzer.py) that contains sales data for a month for three products over 20 days. Your task is to complete the empty functions to analyze this data using basic Python skills: loops, conditionals, and data structures. This project will assess your ability to process and extract information from a dataset, preparing you for data science concepts.

  • The data is stored in a variable called sales_data, a list of 20 dictionaries. Each dictionary represents a day and has:
    • "day": Day number (1 to 20).
    • "product_a": Sales of Product A.
    • "product_b": Sales of Product B.
    • "product_c": Sales of Product C.

Example:

1{"day": 1, "product_a": 150, "product_b": 80, "product_c": 200}
  • Complete the five placeholder functions in the file.

  • Each function analyzes the sales_data in a specific way. Use only basic Python, no external libraries. The file includes print statements to test your work.

Functions to Complete:

  • total_sales_by_product(data, product_key): Calculate the total sales of a given product (e.g., "product_a") over 20 days.

  • average_daily_sales(data, product_key): Calculate the average daily sales of a given product.

  • best_selling_day(data): Find the day with the highest total sales (sum of the three products).

  • days_above_threshold(data, product_key, threshold): Count how many days the sales of a product exceeded a given threshold (e.g., 18).

  • top_product(data): Identify which product (A, B, or C) had the highest total sales.

  • To test your code, run the following command in the command line:

    1python3 monthly_sales_analyzer.py

Feeling confident? 😎:

  • Add a function to find the day with the worst sales.

  • Sort the days by total sales and show the top 3.

  • Calculate the range (maximum - minimum) of the sales of a product.

In the end, you will have practiced handling a realistic dataset with basic Python, developing skills for your next data science course.

Have fun analyzing!🚀

🚛 How to deliver this project

Once you complete the exercises, follow these steps to submit them correctly:

  1. Save and commit the changes in your local repository:

    1git add . 2git commit -m "Completed exercises"
  2. Push the changes to GitHub with:

    1git push origin main

Signup and get access to this project for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Technologies

Difficulty

  • easy

Technologies

Difficulty

  • easy

Technologies

Difficulty

  • easy

Technologies

Signup and get access to this project for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Technologies

Difficulty

  • easy

Technologies