Question: Can Anyone help my code is not working it shows error like expected an indented block Using the file: Purchases.csv. Write a program that will

Can Anyone help my code is not working

it shows error like expected an indented block

Using the file: "Purchases.csv".

Write a program that will provide the following information (displayed on the screen):

1) The total number of purchase orders.

2) The average purchase showing three decimals.

3) The Number of Purchases over 1,800.

4) The average amount of Purchases over 1,800 showing three decimals.

Present you output in some Tabular format. Something similar to:

Total Number of Purchases: xxxx

Amount of Average Purchase: xxxx.xxx

Number of Purchase Orders over $1,800: xxxx

Amount of Average Purchase over $1,800: xxxx.xxx

import csv

data = []

purchases = csv.reader(open('Purchases.csv', 'rb'))

for value in purchases: data.append(float(value[0]))

total_purchase = len(data) print("Total Number of Purchase: {}".format(total_purchase)) print("Amount of Average Purchase: {:.3f}".format(sum(data)/total_purchase))

purchase_over_1800 = sum(1 for i in data if i>1800) print("Number of Purchase Orders over $1,800: {}".format(purchase_over_1800)) print("Amount of Average Purchase over $1,800: {:.3f}".format(sum([i for i in data if i>1800])/purchase_over_1800))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!