Dictionary Practice Questions
Dictionary Practice Questions
Scenario:
You are working as a student database manager at a university. You need to manage and
process student records using a dictionary.
Tasks:
1- Create a dictionary named students_data where each student's roll number is the
key, and the value is another dictionary containing:
students_data = {
"S101": {"Name": "Ali Ahmed", "Age": 20, "Marks": {"Math": 85, "Science": 90, "English": 88}},
"S102": {"Name": "Sara Khan", "Age": 22, "Marks": {"Math": 78, "Science": 85, "English": 80}},
"S103": {"Name": "Tayyab Khushi", "Age": 21, "Marks": {"Math": 92, "Science": 95, "English": 89}}
2- Write a function to display the details of a student when the roll number is provided as
input.
3- Write a function to calculate and print the average marks of each student.
4- Write a function to find and print the name of the student with the highest total
marks.
5- Write a function to add a new student record dynamically by taking user input for roll
number, name, age, and marks.
Scenario:
You are working as a data analyst for a university’s student record system. You have been given
a dictionary containing information about students. Your task is to process, analyze, and
manipulate this data using Python dictionaries.
students_data = {
Tasks:
1. Convert the given dictionary into a list of dictionaries where each student’s details are
stored as an individual dictionary inside a list.
{'Name': 'Abdur Rehman', 'Age': 30, 'Gender': 'M', 'City': 'Lahore', 'Qualification': 'PhD'},
{'Name': 'Muhammad Qasim', 'Age': 5, 'Gender': 'M', 'City': 'Multan', 'Qualification': 'MS'},
...
2. Write a function that allows the user to search for a student by name and display their
details.
3. Write a function to find all students from a specific city (e.g., input "Lahore" should
return both "Abdur Rehman" and "Maryam").
4. Write a function that counts and displays the number of male and female students in
the dataset.
5. Write a function to find the student with the highest qualification level (PhD → highest,
Inter → lowest). Use the given order: PhD > MS > BS > Inter
6. Write a function that adds a new student’s record dynamically by taking user input for
name, age, gender, city, and qualification.
7. (Bonus Task) Convert the list of dictionaries into a Pandas DataFrame and display it.
~~ Best of Luck ~~