Question: python help me. Given the following data file data.txt. Write a Python program to read the class name and a series of scores then find

python help me.

Given the following data file "data.txt". Write a Python program to read the class name and a series of scores then find the average, the lowest and the highest score for the class and print the result in the form shown below.

Sample Input file: CSci 1 90 100 89 78 67 Output format: Class High Low Average CSci1 100 67 77.5

my code is not worked

my code:

fileName = input("Enter file name and path: ")

fin = open(fileName)

ct = 0

total = 0

cla=str(fin)

for line in fin:

x = int(line)

if ct == 0:

high = x

low = x

else:

if high < x :

high = x

elif low > x :

low = x

total += x

ct += 1

if ct > 0 :

avg = total /ct

print( "%-20s%-15s%-15s%-15s%"%("Class","High","Low","Average" ))

print("%-20s%-15f%-15f%-15f%"%(cla, higt, low, avg))

else:

print("No data was processed. ")

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!