I'm very new to coding so my apologies if I'm saying any of this wrong. I am trying to write a code for this prompt:
A company has 3 divisions. After inputing the sales for each division across 4 quarters, I want to print the average sales for each division. Below is the code:
Here is my problem. When I run the code, it prompts me to "Enter sales". And then after I do it four times, it tells me the average. How can I write this code so that it will ask me to enter the sales for Division 1 Quarter 1, Division 1 Quarter 2, Division 2 Quarter 2 etc. and then it will print "The average sales for Division 1 were...", "The average sales for Division 2 were..."
THANK YOU
A company has 3 divisions. After inputing the sales for each division across 4 quarters, I want to print the average sales for each division. Below is the code:
1 2 3 4 5 6 7 8 9 10 11 |
divisions = 3 while divisions > 0 : total = 0 quarters = 4 while quarters > 0 : sales = float ( input ( "Enter sales: " )) total + = sales quarters - = 1 average = total / 4 divisions - = 1 print ( "The average for division" , divisions + 1 , "is $" , format (average, '.2f' )) |
THANK YOU
buran write Apr-14-2021, 03:16 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.