Ibra Electricity Company has an automated system that calculates the total bill for each area in a given city. The system gets to know the number of areas from the electricity manager. For each area it asks the number of families in the area. For each family it asks the number of units used and then calculates the total price for the family with the price per unit being 0.4 OMR. It also calculates the sum of the units used for each family in an area and displays that. First, read the number of areas. Then, for each area, read the number of families. For each family read the number of units used and calculate the total price. Along with this calculate the total number of units used in an area by finding the sum of each family’s usage. Finally display the total number of units for each area.
Write a Python Program to solve the following problem using NESTED LOOP:
Ibra Electricity Company has an automated system that calculates the total bill for each area in a given city. The system gets to know the number of areas from the electricity manager. For each area it asks the number of families in the area. For each family it asks the number of units used and then calculates the total price for the family with the price per unit being 0.4 OMR. It also calculates the sum of the units used for each family in an area and displays that. First, read the number of areas. Then, for each area, read the number of families. For each family read the number of units used and calculate the total price. Along with this calculate the total number of units used in an area by finding the sum of each family’s usage. Finally display the total number of units for each area.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images