Project Level 2: Intermediate
This project is designed for intermediate learners who know Python fundamentals and are practicing building complete programs.
Project Description
This project is about creating a program that runs on the terminal and lets the user store student names and their grades.
How the Project Works
(1) Start the program by defining an empty dictionary on top of the Python script:
grades = {}
The program should get student names and grades from the user and update the grades dictionary (e.g., grades = {“John Smith“: “A+”, “Sarah Smith”: “B”})
(2) To get the data from the user, the program prints out the instructions and prompts the user to choose an option, 1, 2, or 3:
(3) If the user enters 1 that means they want to add a student and their grade. Therefore, the program prompts the user to enter a student name (e.g., John Smith), and a grade (e.g., A):
(4) Once the user submits the grade, the program should add that student-grade pair to the grades dictionary. Then, the program lets the user know that the student and the grade were added. Then, the process is repeated to let the user add more student-grade pairs.
If the user chooses option 2, the student and their grades should be printed out in the terminal. If they choose 3, the program should exit.
Prerequisites
Required Libraries: No libraries are required.
Required Files: No files are required.
IDE: You can use any IDE on your computer to code the project.
Danger Zone
Once you code the project, compare it with our solution below:
grade={}
while True:
print("Menu")
choice= input("""1. Add a student and their grade .
2. View all students and their grade.
3.Exit
Enter your choice """)
if choice=='1':
name=input("Please enter the name of the student")
grade1=input("Please enter the grade of the student")
grade.update({name:grade1})
print("{}'s grade has been added".format(name))
elif choice =='2':
print(grade)
else:
break