7.6k views
1 vote
When a Python program is reading a file, the data is input as plain ASCII characters in a string. What is the following code doing assuming a file is opened with file object inputFile? r_in = inputFile.readline() t = 0 while r_in != '': r = r_in.rstrip('\\') r_list = r.split('|') n = float(r_list[2]) t += n r_in = inputFile.readline()

1 Answer

1 vote

Answer:

The given python code mainly add values.

Step-by-step explanation:

In the given python code, a r_in variable is defined, that reads a file in the next line, a while loop is declared, inside the loop "r_in" variable is used that provides slicing in the code.

  • In this code, in the file, each line is the format in field 1 and field 2.
  • The code puts its fields into the list first and then converts into the last dimension to the numerical type before applying to a sum.

User ACRL
by
5.2k points