Question: For the following questions indicate what the code will print or write to a file. If an error is produced, write down the output printed

 For the following questions indicate what the code will print or

For the following questions indicate what the code will print or write to a file. If an error is produced, write down the output printed before the error is encountered, and then write Error. Write the answer in the box provided.

a) [2 marks] L = [1, 2, 3, 4] for i in range(len(L)): L.remove(L[i]) print(L) b) [2 marks] num = 20 acc = set() while num > 0: num = num - 5 num_sq = int(num ** 0.5) acc = acc.union({num_sq}) print(acc) c) [3 marks] grades = [['Name', 'T1', 'T2', 'T3'], ['Tom', 100, 90, 80], ['Mary', 90, 80, 85], ['Mark', 50, 40, 0], ['Sam', 25, 75, 30]] myfile = open('new_grades.txt', 'w') for row in grades[1:]: avg_grade = sum(row[1:])/3 if avg_grade >= 50: myfile.write(row[0] + ',') myfile.write(str(avg_grade)) myfile.write(' ') myfile.close()

For the following questions indicate what the code will print or write to a file. If an error is produced, write down the output printed before the error is encountered, and then write "Error". Write the answer in the box provided. a) [2 marks] for i in range (len (L)): L. remove (L[i]) print (L) b) |2 marks] num 20 acc - set () while num > 0: num num - 5 num_sq- int (num *0.5) acc -acc.union (Inum sq)) int (num 0.5) print (acc) c) |3 marks] grades['Name','Tl', 'T2','T3'], [ 'Tom', 100, 90, 80], ['Mary', 90, 80, 85], ['Mark', 50, 40, 0], ['Sam', 25, 75, 301 "new_grades.txt" myfileopen ('new grades.txt', 'w') for row in grades [1:]: avg grade-sum (row [1])/3 if avg_grade50: myfile.write (row [0]+',') myfile.write (str (avg grade)) myfile.write('In') myfile.close(

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!