Question

In: Computer Science

Fill in the format strings so that the print() statements below display the indicated values vertically aligned

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.

Solutions

Expert Solution

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)


Related Solutions

Print out screenshot(s) that show the result of setting the prompt to different values as indicated....
Print out screenshot(s) that show the result of setting the prompt to different values as indicated. Remember that you can change the prompt to include the result of a UNIX command if you include the command name in backquotes. To get credit for each step, you must have the screenshot show the command you used to set the prompt and that it worked as intended. Set the prompt to the UNIX server’s name and an arrow by using the hostname...
How to print output vertically in the code attached below: import operator with open ('The Boy...
How to print output vertically in the code attached below: import operator with open ('The Boy .txt',encoding='utf8') as my_file: contents=my_file.read() l = contents.strip() words = l.split() newdict = dict() for i in words: if i in newdict: newdict[i] = newdict[i] + 1 else: newdict[i] = 1 newly = dict() sorted_Dict = sorted(newdict.items(), key=operator.itemgetter(1), reverse=True) for n in sorted_Dict: newly[n[0]] = n[1] print(newly) with open('freqs.txt','w', encoding='utf8') as final: final.write(str(newly))
VIII. a. Fill in the appropriate numerical values in the table below for the surplus or...
VIII. a. Fill in the appropriate numerical values in the table below for the surplus or shortage of baseball caps in the fourth column and the effect on price in the fifth column. Market Demand and Supply Schedules for Baseball Caps Price ($ per cap) Quantity demand-ed (caps per week) Quantity supplied (caps per week) Surplus (+) or Shortage (-) Effect on Price (up or down) $25 8000 14000 $20 9000 12000 $15 10000 10000 $10 11000 8000 $5 12000...
In this exercise, find the values of the unknown constants so that the indicated conditions are met for each function:
In this exercise, find the values of the unknown constants so that the indicated conditions are met for each function: (a) f(t) = At2 + B; given f(0) = 2 and f(−2) = −10. (b) f(t) = Ct3 + D; given f(0) = −5 and f(3) = 49. (c) f(t) = A t 2 + B , given f(0) = 3 and f(−2) = 1.5 (d) f(t) = A t + B , given f(2) = 0.4 and f(8) =...
import math print("RSA ENCRYPTION/DECRYPTION") print("*****************************************************") #Input Prime Numbers print("PLEASE ENTER THE 'p' AND 'q' VALUES BELOW:")...
import math print("RSA ENCRYPTION/DECRYPTION") print("*****************************************************") #Input Prime Numbers print("PLEASE ENTER THE 'p' AND 'q' VALUES BELOW:") p = int(input("Enter a prime number for p: ")) q = int(input("Enter a prime number for q: ")) print("*****************************************************") #Check if Input's are Prime '''THIS FUNCTION AND THE CODE IMMEDIATELY BELOW THE FUNCTION CHECKS WHETHER THE INPUTS ARE PRIME OR NOT.''' def prime_check(a): if(a==2): return True elif((a<2) or ((a%2)==0)): return False elif(a>2): for i in range(2,a): if not(a%i): return false return True check_p =...
Fill in the missing values in the table below given that , dy/dt = 0.8y -...
Fill in the missing values in the table below given that , dy/dt = 0.8y - 2 . t 0 1 2 3 4 y 8 ?? ?? ?? ??
Get values for min and max using assignment statements and the input function. Print min and...
Get values for min and max using assignment statements and the input function. Print min and max. Run the script. fix any errors you find. Remove the print statements you wrote above. Print the labels "Kelvin" and "Fahrenheit". Print a line of dashes under the labels. Run the script. fix any errors you find. Write a for loop that will give the loop variable kelvin values between min and max. Inside the code block print the value of kelvin Run...
Question 9: pi = 3.14159 formatted = _______.format(pi) print("Pi day sale! All pies", formatted, "off.") Fill...
Question 9: pi = 3.14159 formatted = _______.format(pi) print("Pi day sale! All pies", formatted, "off.") Fill in the blank so that the following program prints: Pi day sale! All pies $3.14 off. Question 11: Complete the following program that keeps asking for a price until the user just presses the enter key. Assume the user only enters floating point values. The program totals the values entered by the user and print out the result. total = 0 while True: ans...
Use the mechanism below to fill in the blanks in the statements. Step 1 A +...
Use the mechanism below to fill in the blanks in the statements. Step 1 A + B → C Step 2 C + D → B + E Substance is a catalyst in this mechanism Substance is an intermediate in this mechanism
For each of the statements given below, indicated “True” or “False”. (a) The address issued by...
For each of the statements given below, indicated “True” or “False”. (a) The address issued by the processor is the address of a location in the cache. (b) The main memory is larger than the cache. (c) All data and instructions stored in secondary memory are also stored in main memory. (d) The cache has a shorter access time than main memory. (e) Main memory is typically constructed using DRAM technology. explain why
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT