An electricity company has developed a new smart electricity meter that allows customers to monitor their electricity consumption and predict how much they will be charged at the end of each week.

The electricity supplier charges customers a fixed rate of 25p per kilowatt-hour (kWh).
A kilowatt-hour is a unit of energy. For example, a 1,000-watt (1 kW) electric heater running for one hour consumes 1 kWh of electricity, costing 25p.
To encourage customers to sign up, the electricity company is also offering a special deal:
One day of free electricity every week!
Effectively, the electricity supplier automatically makes the day with the lowest electricity consumption free of charge.
This means that customers will only pay for the electricity they have used on the remaining six days of the week.
The electricity company needs your help to develop the software that will run on its new smart meter.
Python Challenge
Your task is to write a Python program that will be integrated into the smart electricity meter to help customers predict their weekly electricity bill.
For this prototype, instead of collecting the readings automatically, the program will ask the customer to enter their electricity consumption for each day of the week.
The program should ask seven questions, such as:
- How many kWh did you use on Monday?
- How many kWh did you use on Tuesday?
- How many kWh did you use on Wednesday?
- … and so on until Sunday.
Once all seven readings have been entered, the smart meter should:
-
Calculate the total electricity consumption for the week.
Calculate the total chargeable electricity consumption and the predicted electricity bill using the rate of £0.25 per kWh.
Identify which day had the lowest electricity consumption and will therefore be free of charge.
Calculate the total chargeable electricity consumption, excluding the free day.
Calculate the predicted electricity bill using the rate of £0.25 per kWh.
Display a summary of the weekly consumption and the predicted bill.
Imagine that the smart electricity meter records the following electricity consumption for a household:
| Day | Electricity Consumption |
|---|---|
| Monday | 12 kWh |
| Tuesday | 9 kWh |
| Wednesday | 11 kWh |
| Thursday | 8 kWh |
| Friday | 14 kWh |
| Saturday | 16 kWh |
| Sunday | 10 kWh |
| Total | 80 kWh |
Step 1: Calculate the total electricity consumption
The household has consumed:
12 + 9 + 11 + 8 + 14 + 16 + 10 = 80 kWh
Step 2: Identify the free electricity day
Thursday has the lowest electricity consumption, with just 8 kWh.
The electricity supplier will therefore not charge the customer for Thursday’s electricity.
Step 3: Calculate the chargeable consumption
80 − 8 = 72 kWh
Step 4: Calculate the predicted electricity bill
72 × £0.25 = £18.00
Without the special offer, the customer would have paid:
80 × £0.25 = £20.00
Thanks to the free electricity day, the customer saves £2.00!
The smart meter should therefore display a predicted weekly electricity bill of £18.00.
To develop your smart electricity meter program, break the problem down into the following steps.
Step 1: Collect the Daily Electricity Readings
The first task is to collect the electricity consumption for each of the seven days.
Use Python’s input() function to ask the customer how many kWh they consumed each day.
Since electricity consumption can include decimal values (e.g. 8.5 kWh), use the float() function to convert the inputs into numerical values.
For example:
monday = float(input("How many kWh did you use on Monday? "))
Repeat this process for the remaining six days.
Hint: You could store each reading in a separate variable or use a Python list to store all seven readings together.
Step 2: Calculate the Total Weekly Consumption
Once all seven readings have been collected, your smart meter needs to calculate the total electricity consumed during the week.
Add together the seven daily readings and store the result in a variable.
Step 3: Find the Free Electricity Day
The smart meter must now identify which day of the week had the lowest electricity consumption.
This is an important step because the customer will not be charged for the electricity consumed on that day.
You will need to find the smallest of the seven readings.
Hint: Python’s built-in min() function can be used to find the smallest value in a list.
You should also try to identify the name of the day that corresponds to this lowest reading so that it can be displayed to the customer.
Step 4: Calculate the Chargeable Electricity Consumption
Now that you have identified the free electricity day, you can calculate how much electricity the customer will actually pay for.
Subtract the electricity consumed on the free day from the total weekly consumption.
Chargeable Consumption = Total Weekly Consumption − Lowest Daily Consumption
Step 5: Calculate the Predicted Electricity Bill
The electricity supplier charges £0.25 for every kWh of electricity consumed.
To calculate the predicted electricity bill, multiply the chargeable consumption by 0.25.
Predicted Bill = Chargeable Consumption × 0.25
Step 6: Display the Smart Meter Summary
Finally, your program should display a clear summary of the customer’s electricity consumption and predicted weekly bill.
For the worked example above, the output could look like this:
====================================
SMART ELECTRICITY METER
====================================
Weekly Electricity Summary
Total consumption: 80.0 kWh
Free electricity day: Thursday
Free electricity: 8.0 kWh
Chargeable consumption: 72.0 kWh
Electricity rate: £0.25/kWh
------------------------------------
PREDICTED WEEKLY BILL: £18.00
------------------------------------
You saved £2.00 this week!
====================================
Once your smart electricity meter is working correctly, consider adding some extra features to make it even more useful to customers.
Extension 1: Calculate the Savings
Modify your program to calculate and display how much money the customer has saved thanks to the free electricity day.
You could also display the savings as a percentage of the original electricity bill.
Extension 2: Validate the Electricity Readings
A smart electricity meter should not accept invalid readings!
Modify your program so that it checks that each daily electricity reading is a positive number or zero.
If the user enters a negative value, the program should display an error message and ask them to enter the reading again.
Extension 3: Identify the Highest Consumption Day
As well as identifying the free electricity day, the smart meter could help customers understand their energy usage by identifying the day when they consumed the most electricity.
Display the name of this day, its consumption in kWh and how much that electricity cost.
Python Code
Complete the code in the IDE provided below:

Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area






