Question

Consider the following list contained in file named input.txt: use (-999) to stop reading grades Khaled...

Consider the following list contained in file named input.txt:
use (-999) to stop reading grades
Khaled 65 78 56 89 -999
Kamal 37 55 44 22 18 56 26 -999
Ali 66 33 87 66 87 25 39 78 -999
Taher 12 67 -999
Write a program to read this information and Output the name and sum for each person.

Note: the number of rows may vary.

Homework Answers

Answer #1

Python Implementation:

# Opening the file file.txt in read mode.
myFile = open("file.txt", "r")  
li = []
# Reading the file line by line and storing it in a list
for x in myFile:
    li.append(x.split(" "))

# Calculating sum of grades and printing name and sum.
for i in li:
    print("Name: ", i[0])
    index = 1
    sum = 0
    while (i[index] != "-999\n"):
        sum += int(i[index])
        index += 1
    print("Grade Sum: ", sum)

# Closing the file.
myFile.close()

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider the following list contained in file named input.txt: using java program Khaled 65 78 56...
Consider the following list contained in file named input.txt: using java program Khaled 65 78 56 89 -999 Kamal 37 55 44 22 18 56 26 -999 Ali 66 33 87 66 87 25 39 78 -999 Taher 12 67 -999 Write a program to read this information and Output the name and sum for each person. Note: the number of rows may vary. Assum -999 as sentenital value
Student Grades Student Test Grade 1 76 62 2 84 90 3 79 68 4 88...
Student Grades Student Test Grade 1 76 62 2 84 90 3 79 68 4 88 84 5 76 58 6 66 79 7 75 73 8 94 93 9 66 65 10 92 86 11 80 53 12 87 83 13 86 49 14 63 72 15 92 87 16 75 89 17 69 81 18 92 94 19 79 78 20 60 71 21 68 84 22 71 74 23 61 74 24 68 54 25 76 97...
Using If and LookUp Formulas Formatting Grades Input boxes in tan Output boxes in yellow Given...
Using If and LookUp Formulas Formatting Grades Input boxes in tan Output boxes in yellow Given data in blue Answers in red Professor Streterstein is a bit absentminded. His instructor’s grade book is a mess, and he would like your help cleaning it up and making it easier to use. In Professor Streterstein’s course, the maximum possible points a student can earn is 750. The following table displays the grade equivalent to total points for the course. Professor Streterstein's Course...
have a java application need to create an application which is able to do some analysis...
have a java application need to create an application which is able to do some analysis on temperature data stored in a data file. You will be given the “temperatures.dat” data file which contains the data you must analyze. The analysis you’ll need to do is: Total number of data points Find coldest temperature Find warmest temperature Find average temperature Find the frequency of each temperature Find the most frequent temperature Find the least frequent temperature All classes must be...
Using the accompanying Student Grades​ data, construct a scatter chart for midterm versus final exam grades...
Using the accompanying Student Grades​ data, construct a scatter chart for midterm versus final exam grades and add a linear trendline. What is the​ model? If a student scores 7878 on the​ midterm, what would you predict her grade on the final exam to​ be? Student Midterm Final Exam 1 75 64 2 85 91 3 80 68 4 88 83 5 76 60 6 67 80 7 78 74 8 95 94 9 67 61 10 93 87 11...
Question 2: Write a C program that read 100 integers from the attached file (integers.txt) into...
Question 2: Write a C program that read 100 integers from the attached file (integers.txt) into an array and copy the integers from the array into a Binary Search Tree (BST). The program prints out the following: The number of comparisons made to search for a given integer in the BST And The number of comparisons made to search for the same integer in the array Question 3 Run the program developed in Question 2 ten times. The given values...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import java.io.*; //This imports input and output (io) classes that we use 3 //to read and write to files. The * is the wildcard that will 4 //make all of the io classes available if I need them 5 //It saves me from having to import each io class separately. 6 /** 7 This program reads numbers from a file, calculates the 8 mean (average)...
And need to be writing in C++ language Programm need to start with   #include<fstream> Prepare a...
And need to be writing in C++ language Programm need to start with   #include<fstream> Prepare a text file data_in.txt with the following information (highlight the piece of text below with numbers and copy it to a text file): 54, 70, 75, 63, 17, 59, 87, 16, 93, 81, 60, 67, 90, 53, 88, 9, 61, 8, 96, 98, 12, 34, 66, 76, 38, 55, 58, 27, 92, 45, 41, 4, 20, 22, 69, 77, 86, 35, 19, 32, 49, 15,...
USING C++ The purpose of this assignment is the use of 2-dimensional arrays, reading and writing...
USING C++ The purpose of this assignment is the use of 2-dimensional arrays, reading and writing text files, writing functions, and program planning and development. You will read a data file and store all of the input data in a two dimensional array. You will perform calculations on the data and store the results in the 2 dimensional array. You will sort the array and print the results in a report. Instructions You will read in the same input file...
The file P17_05.xlsx contains data on 100 consumers who drink beer. Some of them prefer light...
The file P17_05.xlsx contains data on 100 consumers who drink beer. Some of them prefer light beer, and others prefer regular beer. A major beer producer believes that the following variables might be useful in discriminating between these two groups: gender, marital status, annual income level, and age. b. Consider a new customer: male, married, income $42,000, age 47. Use the logistic regression equation to estimate the probability that this customer prefers Regular. How would you classify this person? Individual...