Question: In Python: There are two issues to keep in mind when reading text files: 1 . Each line ends in a newline character. Use the

In Python:
There are two issues to keep in mind when reading text files:
1. Each line ends in a newline character. Use the strip() method to remove it.(Refer to lecture on Text Files.)
2. The data is stored as a string. Just as we have with user input, we need to convert to int (or float) if we want to process numeric data.
Step 1: Use Notepad, TextEdit, or a program (see previous exercises) to create a text file called gameScores.txt. Enter several arbitrary scores, each on a separate line. For example:
gameScores.txt TextEdit
5
10
7
12
Step 2: Write a program to read gameScores.txt, one line at a time, to calculate the total score. Display the total when finished. For example:
Total: 34
No comments required. You may copy-paste your code into the textbox below, or attach your program file using the Documents button.

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!