tauk

Total and Average Rent using for loop and input

Jun 16th, 2020
1,449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #initialize total_rent to 0
  2. total_rent = 0
  3.  
  4. #use for loop to enter rents for 10 shops
  5. for i in range(10):
  6.     shop_rent = float(input("Enter rent:"))
  7.     # add the shop_rent to the total_rent
  8.     total_rent = total_rent + shop_rent
  9.  
  10. # calculate the average rent
  11. average_rent = total_rent / 10
  12.  
  13. # output the total rent and the average rent
  14. print("Total Rent is AED: ", total_rent)
  15. print("Average rent is AED:", average_rent)
Advertisement
Add Comment
Please, Sign In to add comment