25.8k views
2 votes
Write a program to prompt the user to enter a fist name, last name, student ID and GPA. Create a dictionary called Student1 with the data. Repeat this for three students and create Student2 and Student3 dictionaries. Store the three students dictionaries to a new dictionary called ClassList. (ClassList will have Student1, Student2 and Student3 as sub dictionaries). Print out the ClassList. Then remove the GPA and print ClassList again.

1 Answer

3 votes

Answer:

Answered below

Step-by-step explanation:

#Program is written in Python

first_name = input ("Enter first name: ")

last_name = input ("Enter last name:")

student_id = int(input("Enter your ID"))

gpa = float(input ("Enter your GPA: "))

student1 = {}

student1["first_name"] = first_name

student1["last_name"] = last_name

student1["student_id"] = student_id

student1["gpa"] = gpa

//Repeat same code for student2 and student3

class_list = {"student1": {"first_name":"joy","last_name":"Son","student_id":"1","gpa":"3.5"},

#Fill in for student 2 and 3}

#To remove GPA for all students

del class_list["student1"]["gpa"]

del class_list["student2"]["gpa"]

del class_list["student3"]["gpa"]

print(class_list)

User Doughy
by
5.4k points