Q.Case Study Based Question
Schools use "Student Management Information System" (SMIS) to manage student related data. This system provides facilities for:
- Recording and maintaining personal details of students.
- Maintaining marks scored in assessments and computing results of students.
- Keeping track of student attendance, and
- Managing many other student-related data in the school.
Let us automate the same step by step.
Identify the personal details of students from your school identity card and write a program to accept these details for all students of your school and display them in this format.
Name of School
Student Name: PQR Roll No: 99
Class: XI Section: A
Address : Address Line 1
Address Line 2
City: ABC Pin Code: 999999
Parent's/ Guardian's Contact No: 9876543210
Let us automate the same step by step.
Identify the personal details of students from your school identity card and write a program to accept these details for all students of your school and display them in this format.
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →This is a program design task requiring a Python application to accept and display student personal details in a formatted layout, demonstrating basic input/output, data structures, and string formatting.
Understanding the Requirement
The question asks you to build a simple Student Management Information System (SMIS) module that handles the most fundamental operation: capturing and displaying student personal details. This is a classic data collection and presentation problem that tests your ability to:
- Identify relevant data fields (from a typical school ID card)
- Structure data using appropriate Python data types
- Accept user input systematically
- Format output for readability
The personal details typically found on a school ID card include: student name, roll number, class, section, address (multi-line), city, pin code, and parent/guardian contact number.
Solution Approach
We'll use a dictionary to store each student's details (key-value pairs make field access intuitive), and a list of dictionaries to manage multiple students. The program will loop to accept details for all students, then display each record in the specified format.
def accept_student_details():
"""Accept personal details for one student"""
student = {}
print("\n--- Enter Student Details ---")
student['name'] = input("Student Name: ").strip()
student['roll_no'] = input("Roll No: ").strip()
student['class'] = input("Class: ").strip()
student['section'] = input("Section: ").strip()
student['address_line1'] = input("Address Line 1: ").strip()
student['address_line2'] = input("Address Line 2: ").strip()
student['city'] = input("City: ").strip()
student['pin_code'] = input("Pin Code: ").strip()
student['parent_contact'] = input("Parent's/Guardian's Contact No: ").strip()
return student
def display_student_details(student, school_name):
"""Display student details in the specified format"""
print("\n" + "="*60)
print(school_name.center(60))
print("="*60)
print()
print(f"Student Name: {student['name']:<20} Roll No: {student['roll_no']}")
print(f"Class: {student['class']:<25} Section: {student['section']}")
print(f"Address : {student['address_line1']}")
print(f" {student['address_line2']}")
print()
print(f"City: {student['city']:<25} Pin Code: {student['pin_code']}")
print(f"Parent's/ Guardian's Contact No: {student['parent_contact']}")
print("="*60)
def main():
"""Main program to manage student records"""
school_name = input("Enter School Name: ").strip()
num_students = int(input("Enter number of students: "))
students = []
# Accept details for all students
for i in range(num_students):
print(f"\n*** Student {i+1} of {num_students} ***")
student = accept_student_details()
students.append(student)
# Display all student records
print("\n\n" + "#"*60)
print("STUDENT RECORDS".center(60))
print("#"*60)
for student in students:
display_student_details(student, school_name)
# Run the program
if __name__ == "__main__":
main()
Key Design Decisions
Dictionary for each student: Each student's data is stored as a dictionary because field names (keys) make the code self-documenting. student['name'] is clearer than student[0].
Separation of concerns: Three functions handle distinct tasks:
accept_student_details()— input logic onlydisplay_student_details()— formatting and output onlymain()— orchestration (how many students, loop control)
This modularity makes the code easier to test and extend.
String formatting with f-strings: The display function uses f-strings with alignment specifiers. For example, f"Student Name: {student['name']:<20}" left-aligns the name in a 20-character field, ensuring the "Roll No:" label lines up neatly even when names have different lengths.
Multi-line address handling: The address is split into two lines as shown in the sample format. Each line is printed with appropriate indentation ("Address : " for line 1, " " for line 2) to maintain visual alignment.
Use .strip() on all inputs to remove accidental leading/trailing whitespace that users often add, which would otherwise misalign your formatted output.
The question says "all students of your school" — in a real scenario this could be hundreds. For practical testing, the program asks for the number of students first. In a production SMIS, you'd use a database rather than in-memory lists, and add one student at a time through a menu-driven interface.
Sample Execution
Input:
Enter School Name: Delhi Public School
Enter number of students: 2
*** Student 1 of 2 ***
--- Enter Student Details ---
Student Name: Priya Sharma
Roll No: 15
Class: XII
Section: B
Address Line 1: 42, Green Park
Address Line 2: Near Metro Station
City: New Delhi
Pin Code: 110016
Parent's/Guardian's Contact No: 9876543210 …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.