Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+5 votes

Do I have to print out the output on the console or in an output file?
Do I have to put things in main() or have it execute directly in the fileAverage?

asked in old_CSC201 by (1 point)

1 Answer

+1 vote

For Routine 8, problem 5; the output goes to the console using print statments, not to a file using write statements.

The code you put in Moodle won't have a main function.

If you want test out your code in Thonny, you would need to organize it this way:

def fileAverage(filename):
     fin = open(filename, 'r')

     # code to read through the file and process it

def main():


You also need a 2nd file with the data values named data1.txt which is in the same folder as the .py file.

The only part that you put in Moodle is the code from def fileAverage(filename): up to, but not including def main():

answered by (1 point)
edited by