Discussions Events Study Material Jobs
Use a nested dictionary of students and their subject marks Using Python - Uniwaly

Explore Diverse Conversations

Use a nested dictionary of students and their subject marks Using Python

Posted By: UmairMehmood Published On: 13 June 2025 At: 13:02 PM

Ask user to input a student name and subject, and display the corresponding mark
 data = { "Ali": {"Math": 85, "Science": 90}, "Sara": {"Math": 78, "Science": 88} } 


Code:

data = {
    "Ali": {"Math": 85, "Science": 90},
    "Sara": {"Math": 78, "Science": 88}
}
 
student_name = input("Enter the student's name: ")
subject_name = input("Enter the subject: ")
 
if student_name in data:
    if subject_name in data[student_name]:
        print(f"{student_name}'s mark in {subject_name} is {data[student_name][subject_name]}")
    else:
        print(f"Subject '{subject_name}' not found for {student_name}.")
else:
    print(f"Student '{student_name}' not found.")



Tags:

python nested dictionary python nested dictionary
Login to like

Posted By:

Author Profile

UmairMehmood

11 days ago

Join the conversation!

Login to Comment

Discover More Articles

وزارت قانون و انصاف حکومت پاکستان میں شاندار نوکریاں

Graphic Designer Jobs in Forest Department , PAKISTAN 2025

National University of Sciences and Technology ( Nust ) Admission Process

Habib University Admission Process

NADRA Internship Program 2025 for All Pakistani Fresher Graduates

How to become a pro in CSS. A Road map to Becoming a CSS Pro.

Al Barik Bank Jobs 2025 in Pakistan - Apply Now

New 30,000 Teaching Jobs Coming Soon on Merit : CM Punjab

Opening a Bank Account for Minors in Pakistan: A Comprehensive Guide

Your Rights Online: How to Report and Delete AI-Generated Fake Content Featuring You