1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olga55 [171]
3 years ago
10

In this assignment we are going to practice reading from a file and writing the results of your program into a file. We are goin

g to write a program to help Professor X automate the grade calculation for a course. Professor X has a data file that contains one line for each student in the course. The students name is the first thing on each line, followed by some tests scores. The number of scores might be different for each student. Here is an example of what a typical data file may look like: Joe 10 15 20 30 40 Bill 23 16 19 22 Sue 8 22 17 14 32 17 24 21 2 9 11 17 Grace 12 28 21 45 26 10 John 14 32 25 16 89 Program details Write a program that: Ask the user to enter the name of the data file. Read the data from the file and for each student calculate the total of the test scores, how many tests the student took, and the average of the test scores. Save the results in an output file (e.g. stats.txt) in the following order: studentName totalScore numberOfTests testAverage Note that the average is saved with 2 decimal places after the decimal point. Validation: Make sure your program does not crash if a file is not found or cannot be open.
Computers and Technology
1 answer:
zhenek [66]3 years ago
6 0

Answer:

In Python:

import os.path

from os import path

fname = input("Filename: ")

if path.exists(fname):

with open(fname) as file_in:

 lines = []

 for line in file_in:

  lines.append(line.rstrip('\n'))

f = open("stat.txt","r+")

f.truncate(0)

f = open("stat.txt", "a")

f.write("Names\tTotal\tSubjects\tAverage\n")

for i in range(len(lines)):

 rowsum = 0; count = 0

 nm = lines[i].split()

 for j in nm:

  if (j.isdecimal()):

   count+=1

   rowsum+=int(j)

 average = rowsum/count

 f.write(nm[0]+"\t %3d\t %2d\t\t %.2f\n" % (rowsum, count, average))

f.close()

else:

print("File does not exist")

Explanation:

See attachment for explanation where comments were used to explain each line

Download txt
You might be interested in
When you use the Filter feature, what appears in each column label
Scrat [10]
<span>an arrow  ..............................</span>
5 0
3 years ago
What should you do if a headset plugged into your computer is not working properly?
Alex777 [14]

If a headset plugged into computer is not working properly than one can go for updating the device driver. The correct option is B.

<h3>What is a device driver?</h3>

A device driver is a type of software application that allows one hardware device (such as a computer) to communicate with another hardware device (such as a printer). A device driver is indeed referred to as a software driver.

A driver, also known as a device driver, is a collection of files that instructs a piece of hardware on how to operate by communicating with a computer's operating system.

Every piece of hardware, from internal computer components like your graphics card to external peripherals like a printer, requires a driver.

If a headset plugged into a computer is not working properly, the device driver can be updated.

Thus, the correct option is B.

For more details regarding device driver, visit:

brainly.com/question/14054807

#SPJ12

8 0
1 year ago
Read 2 more answers
Proxy servers and ACLs on network devices are examples of non-security devices with security features, while firewalls and IDS/I
RideAnS [48]

Answer:

True.

Explanation:

A proxy server, for example, can hide the true origin of a request, thus, keeping your IP address private, and non-visible to the internet. However, this won't necessarily keep malicious attackers from reaching your network. A proxy simply acts as an intermediary between you, and the server you are trying to reach.

Firewalls or an Intrusion Detection Systems (IDS) are pieces of software specifically designed to keep attackers out of your system, they can analyze the web traffic and detect malware, or they can prevent the delivery of some packages, based on its content if the IDS consider it's malicious.

6 0
3 years ago
Although there are three well-known operating systems, the most common are Microsoft Windows and Mac OS. Discuss the similaritie
tiny-mole [99]

Answer:

There are very few similarities beyond some convergent features of their respective user interfaces. Their internal architecture is very different, differing from kernel models to shell integration to executable formats. A comprehensive list of similarities is neither possible nor useful, because it would consist mostly of obvious statements like "They are both operating systems" or "They both have graphical user interfaces, "They both include

Explanation:

How's that?

7 0
2 years ago
What is an adaptive test? A. A test that adjusts the difficulty of the questions based on the student's answers to previous ques
san4es73 [151]
Answer:
Is B I think So don’t be in a comments trying to come for me

Step by step explanation:
3 0
2 years ago
Other questions:
  • Can you know what time someone retweeted
    5·1 answer
  • What are some tasks for which you can use the VBA Editor? i need help for my computer class.
    5·1 answer
  • Jump to Question: Fill in the blanks below: The flow of electricty is similar to the movement of water through a pipe. The movem
    15·1 answer
  • An example of a current disruptive technology is a?
    8·2 answers
  • Will give Brainiest and stuff to right answer[s].
    12·2 answers
  • ) Doyou know applets and Java Beans in Java? Please briefly state eachone with an example.
    10·1 answer
  • Which of these jobs would be most appropriate for someone who majors in information technology? A)developing new computing techn
    5·2 answers
  • This matches the domain name with the correct IP address:
    12·1 answer
  • What is the purpose of system software?
    8·1 answer
  • Which file extension indicates a text document? .ppt .tst .pdf .txt
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!