Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 7 : Grade Database In this problem, you will be displaying ( fictional ) grade information that is assumed to be taken fr database.

Problem 7: Grade Database
In this problem, you will be displaying (fictional) grade information that is assumed to be taken fr
database. The information is stored in two dictionaries and three lists, as shown below.
Copy the code below into a code cell, and then execute that cell.
students ={
146832:{'first':'Brendan', 'last':'Small'},
147354:{'first':'Melissa', 'last':'Robbins'},
149126:{'first':'Jason', 'last':'Penopolis'},
149735:{'first':'Fenton', 'last':'Mulley'}
}
courses ={
'ENGL 101':'Composition I',
'ENGL 104':'Composition II',
'MATH 117':'College Algebra',
'MATH 151':'Calculus I',
'CHEM 103':'General Chemistry I',
'ECON 201':'Macroeconomics'
}
sid =[149126,146832,147354,149735,149126,146832,
146832,149735,149126,147354,147354,149735]
cid =['ENGL 101', 'MATH 117', 'ENGL 104', 'CHEM 103', 'MATH 117', 'ECON 201',
'ENGL 101', 'ENGL 101', 'CHEM 103', 'ENGL 104', 'MATH 151', 'MATH 117']
grade =['D','C','B','A','B','C',
'A','F','B','A','A','C']
The students dictionary is a lookup table that allows you to obtain the name of a student based on their Student ID
number. The courses dictionary is a lookup table that allows you to obtain the name of a course based on the Course ID
(which consists of a department name and course number). The lists sid, cid, and grade are parallel lists that represent
columns from a grade database. The sid list contains student ID numbers associated with 12 different records form the
database, the cid list contains course ID information for the 12 records, and the grade list contains the grade obtained by
the corresponding student in the corresponding course.
Use a loop to print a table displaying the twelve records. The table should be formatted as follows:
The first row of output should contain column headers.
The second row should be a dividing line consisting of 69 dashes.
The table should have columns for student ID, first name, last name, course id, course name, and grade.
The number of characters reserved for each column should be 9,10,12,11,22, and 5(in that order).
All columns should be left-aligned except for the grade column, which should be right-aligned.
The first few rows rows of the output are shown below. Try to match the format of this output exactly.
SID First Last CID Course Name Grade
-------------------------------------------------
149126 Jason Penopolis ENGL 101 Composition I D
146832 Brendan Small MATH 117 College Algebra C

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions