0
0
GCPcloud~30 mins

Cost management with billing reports in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Cost management with billing reports
📖 Scenario: You work in a company that uses Google Cloud Platform (GCP). Your manager wants you to create a simple billing report to track monthly costs for different projects. This will help the team understand where money is spent and plan budgets better.
🎯 Goal: Build a basic Python script that stores monthly billing data for GCP projects, sets a budget threshold, calculates total costs, and flags projects that exceed the budget.
📋 What You'll Learn
Create a dictionary with project names as keys and their monthly costs as values
Add a budget threshold variable to compare costs against
Calculate the total cost of all projects
Identify and list projects that exceed the budget threshold
💡 Why This Matters
🌍 Real World
Companies use billing reports to track cloud spending and avoid unexpected charges.
💼 Career
Cloud engineers and financial analysts often create scripts to monitor and manage cloud costs efficiently.
Progress0 / 4 steps
1
Create the billing data dictionary
Create a dictionary called billing_data with these exact entries: 'project-alpha': 1200, 'project-beta': 850, 'project-gamma': 430, 'project-delta': 670 representing monthly costs in dollars.
GCP
Need a hint?

Use curly braces {} to create a dictionary with keys and values separated by colons.

2
Set the budget threshold
Add a variable called budget_threshold and set it to 1000 to represent the maximum allowed monthly cost per project.
GCP
Need a hint?

Use a simple assignment statement to create the variable.

3
Calculate total monthly cost
Create a variable called total_cost and set it to the sum of all values in the billing_data dictionary using the sum() function and billing_data.values().
GCP
Need a hint?

Use sum() with billing_data.values() to add all costs.

4
List projects exceeding the budget
Create a list called over_budget_projects using a list comprehension that includes project names from billing_data where the cost is greater than budget_threshold.
GCP
Need a hint?

Use a list comprehension with for project, cost in billing_data.items() and an if condition.