Question: My code is not importing the scores 2 txt file. Can you please help? # Open the file and read the lines with open (

My code is not importing the scores2 txt file. Can you please help?
# Open the file and read the lines
with open("scores2.txt") as file:
lines = file.readlines()
# Process lines
for line in lines:
# put in name and scores
parts = line.strip().split(',')
name = parts[0]
scores = list(map(int, parts[1:]))
# Calculate the average and standard deviation
avg = sum(scores)/ len(scores)
std_dev = statistics.stdev(scores)
# final result
scores_str =''.join(map(str, scores))
print(f"{name}{scores_str}={avg:.2f}({std_dev:.2f})")

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!