Computer Science, asked by vardhanbonam7, 6 months ago

Write nested for loop to get sales amount of 3 products in 4 places
and print.

Answers

Answered by Saipavan55
3

Answer:

tot=0

for i in range(1,5):

   place=input('ENTER YOUR PLACE:')

   for j in range(1,4):

       sales=int(input('ENTER SALES AMOUNT OF '+str(j)+ ' PRODUCT:'))

       tot+=sales

   print('PLACE:',place)

   print('TOTAL SALES=',tot)

OUTPUT:

ENTER YOUR PLACE:CHENNAI

ENTER SALES AMOUNT OF 1 PRODUCT:1200

ENTER SALES AMOUNT OF 2 PRODUCT:211

ENTER SALES AMOUNT OF 3 PRODUCT:333

PLACE: CHENNAI

TOTAL SALES= 1744

ENTER YOUR PLACE:ANDHRA PRADESH

ENTER SALES AMOUNT OF 1 PRODUCT:655

ENTER SALES AMOUNT OF 2 PRODUCT:4322

ENTER SALES AMOUNT OF 3 PRODUCT:123

PLACE: ANDHRA PRADESH

TOTAL SALES= 6844

ENTER YOUR PLACE:BANGLORE

ENTER SALES AMOUNT OF 1 PRODUCT:743

ENTER SALES AMOUNT OF 2 PRODUCT:622

ENTER SALES AMOUNT OF 3 PRODUCT:532

PLACE: BANGLORE

TOTAL SALES= 8741

ENTER YOUR PLACE:ODISHA

ENTER SALES AMOUNT OF 1 PRODUCT:853

ENTER SALES AMOUNT OF 2 PRODUCT:6421

ENTER SALES AMOUNT OF 3 PRODUCT:543

PLACE: ODISHA

TOTAL SALES= 16558

Explanation:

In Above, you can see that for loop prints place(4 times) and print enter sales(3 times). For summing all the sales, you need to just keep[x=0] and just add it to sales[x+=sales]

and just print

HOPE IT HELPS YOU

Similar questions