Question: Report Structure: explain the results. students = { } def add _ student ( ) : for i in range ( 1 , 6 )

Report Structure:
explain the results.
students ={}
def add_student():
for i in range(1,6):
print(f"Enter information for student {i}:")
student_id = str(input("ID: "))
gpa = float(input("GPA: "))
name = input("Name: ")
age = int(input("Age: "))
student ={"ID": student_id, "GPA": gpa, "Name": name, "Age": age}
students[student_id]= student
def search_student(student_id):
student = students.get(student_id)
if student:
return student
else:
return None
def show_students():
if students:
for student_id, student in students.items():
print("Student Information:")
print(f"ID: {student['ID']}")
print(f"GPA: {student['GPA']}")
print(f"Name: {student['Name']}")
print(f"Age: {student['Age']}")
print("------------------------")
else:
print("No students to display.")
while True:
print("Menu: ")
print("1. Add student")
print("2. Search student")
print("3. Show all students")
print("4. Exit")
choice = int(input("Choose 1-4: "))
if choice ==1:
add_student()
elif choice ==2:
student_id = str(input("Enter ID of student to search for: "))
result = search_student(student_id)
if result:
print("Student found!")
print(result)
else:
print("Student not found.")
elif choice ==3:
show_students()
elif choice ==4:
print("Exiting program")
break
else:
print("Invalid choice. Please choose 1-4.")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!