In: Computer Science
ET574 Dictionary (Chapter 6)
1) Create a dictionary containing the following pieces of
information about a student:
Her name is Emmylou; She is on track to graduate in Fall 2021; Her
bill is paid; Her major is Archeology; She belongs to these school
clubs – Photography, Acting and Glee
(Your job as the programmer is to choose the best data type as well as any key names you will use within the program)
2) Do the same for another student:
His name is Javier; He is on track to graduate in Spring 2021; His
bill is unpaid; His major is Math; He belongs to these school clubs
– Archery and Acting
3) Create a list whose contents is the dictionaries you created in step 1 & 2.
Solution to the above python problem is provided below, In case of any help needed regarding the solution. Feel free to write into the comment section of the Solution.
Solution:
# Main function
def main():
# Emmylou dictonary
student_1_dict = {'name':'Emmyolus','graduation_period':'Fall 2021','bill_status':'paid','major_course':'Archaelogy','school_clubs':['Photography','Acting','Glee']}
# Javier dictonary
student_2_dict = {'name':'Javier','graduation_year':'Spring 2021','bill_status':'unpaid','major_course':'Math','school_clubs':['Archery','Acting']}
# Above dictonaries keep in list
dict_to_list = [ student_1_dict ,student_2_dict ]
"""
# this code is just for testing
print("Student 1 Data ",student_1_dict)
print("Student 2 Data ",student_2_dict)
print("Data after converting to list : ", dict_to_list)
"""
# Calling main function
main()
Explaination of Code:
Main() functional contains the code full filling the user requirements.
There are two dictionaries in main function which contains information about students named Emmylou and Javier.
In the last step the data from the dictionary is converted into list.
ScreenShot of output:
End of Solution