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
What is the HIPAA Privacy rule, and why does it affect IT professionals?
CaHeK987 [17]

Solution:

The HIPAA Privacy Rule establishes national standards to protect individuals' medical records and other personal health information and applies to health plans, health care clearinghouses, and those health care providers that conduct certain health care transactions electronically.

IT affects it by these ways:

The HIPAA Privacy Rule for the first time creates national standards to protect individuals’ medical records and other personal health information.

• It gives patients more control over their health information.

• It sets boundaries on the use and release of health records.

• It establishes appropriate safeguards that health care providers and others must achieve to protect the privacy of health information.

• It holds violators accountable, with civil and criminal penalties that can be imposed if they violate patients’ privacy rights.

• And it strikes a balance when public responsibility supports disclosure of some forms of data – for example, to protect public health.

This takes for patient.

• It enables patients to find out how their information may be used, and about certain disclosures of their information that have been made.

• It generally limits release of information to the minimum reasonably needed for the purpose of the disclosure.

• It generally gives patients the right to examine and obtain a copy of their own health records and request corrections.

6 0
3 years ago
Individuals and businesses have concerns about data security while using Internet-based applications. Which security risk refers
Katen [24]

Answer:

Spam

Explanation:

If you receive in bulk the unsolicited messages, then that does mean that your inbox is being spammed. This will not harm you but you will lose the Gb that is allocated to your mailbox. And if you will not check then your mailbox will soon be full, and you might not receive some of the important messages that you should reply to immediately.

6 0
3 years ago
What is is the privacy risks with health care robots?
Ann [662]
Health care robots the key word, being "robots" aren't able to act as we can as humans.

Robots and systems lack the emotional skills that we as humans have, they are not intuitive.

There are many risks in using robots for health care, although, "health care" is a vague term, so I'll cover a few in general:
- Doctor/patient confidentiality is risked when using robots to handle personal medical matters, systems are never 100% secure.

- Robots and systems cannot emphasise with patients and will make decisions based on logic and theoretics, not emotionally - for example, if a patient is in a state of bad mental health, a robot will not be able to effectively analyse the right methods to take.

- The collection, storage and passing-on of patient information is risked as system encryption is never guaranteed.
3 0
3 years ago
If a surface is. it is exactly vertical
Jobisdone [24]
What are the choices
8 0
3 years ago
Which audio file type was created specifically for use on the Internet?
faltersainse [42]
I believe MP3 like 89% sure
6 0
3 years ago
Read 2 more answers
Other questions:
  • You notice that lately your computer has been running slow. When you open up your web browser, you get endless pop-up ads to the
    8·1 answer
  • If you need to use a custom theme frequently, you can save a presentation file as a(n) ____ theme file.
    12·2 answers
  • 4. How can you select non-adjacent cells (i.e. cells that are not all together in one block)?
    5·2 answers
  • Which relation is created with the primary key associated with the relationship or associative entity, plus any non-key attribut
    6·1 answer
  • Select the correct answer.
    15·2 answers
  • In two to three sentences, describe one advanced search strategy and how it is useful.
    13·1 answer
  • The 10 and 2 o'clock hand position on the steering wheel is no longer recommended because _____.
    13·1 answer
  • Help please not trying to fail
    13·1 answer
  • 2. To ________
    7·1 answer
  • Select the correct technical term for each definition by using the drop-down menus.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!