In: Computer Science
Use python
Fill in the format strings so that the print() statements below display the indicated values vertically aligned as Class | Exam Type | Grade ---------- | ---------- | ------------- ECC102 | Midterm | 78.12 ECC104 | Final | 82.45 ECC108 | Makeup | 98.00 ECC200 | Resit | 100.00 Note that the Class column is aligned LEFT, Exam Type column is aligned MIDDLE, and Grade column is also aligned LEFT. Note also that you need to use the vertical bar character | to separate the columns and just the right number of --- characters to separate the column headings from the values in the table.
exam = [['ECC102','Midterm','78.12'],['ECC104','Final','82.45'],['ECC108','Makeup','98.00'],['ECC200','Resit','100.00']];
str1 = 'Class';
str2 = 'Exam Type';
str3 = 'Grade';
empty = '';
print(str1.ljust(10),'|',str2.center(10),'|',str3.ljust(10));
print(empty.center(10,'-'),'|',empty.center(10,'-'),'|',empty.center(10,'-'));
for i in range(len(exam)):
print(exam[i][0].ljust(10),'|',exam[i][1].center(10),'|',exam[i][2].ljust(10));
Output: (Script on the left, output on the right)