KnowledgeBoat Logo
|

Computer Science

Can you store the details of 10 students in a dictionary at the same time ? Details include - rollno, name, marks, grade etc. Give example to support your answer.

Python

Python Dictionaries

11 Likes

Answer

n = 10
details = {}

for i in range(n):
    name = input("Enter the name of student: ")
    roll_num = int(input("Enter the roll number of student: "))
    marks = int(input("Enter the marks of student: "))
    grade = input("Enter the grade of student: ")
    details[roll_num] = [name, marks, grade]
    print()
print(details)

Output

Enter the name of student: Sushma
Enter the roll number of student: 4
Enter the marks of student: 56
Enter the grade of student: C

Enter the name of student: Radhika
Enter the roll number of student: 3
Enter the marks of student: 90
Enter the grade of student: A+

Enter the name of student: Manika
Enter the roll number of student: 45
Enter the marks of student: 45
Enter the grade of student: D

Enter the name of student: Mitanshu
Enter the roll number of student: 1
Enter the marks of student: 23
Enter the grade of student: F

Enter the name of student: Anshika
Enter the roll number of student: 7
Enter the marks of student: 77
Enter the grade of student: B

Enter the name of student: Purva
Enter the roll number of student: 9
Enter the marks of student: 99
Enter the grade of student: A+

Enter the name of student: Sanjana
Enter the roll number of student: 3
Enter the marks of student: 76
Enter the grade of student: B+

Enter the name of student: Priyanka
Enter the roll number of student: 2
Enter the marks of student: 89
Enter the grade of student: A

Enter the name of student: Anand
Enter the roll number of student: 6
Enter the marks of student: 100
Enter the grade of student: A+

Enter the name of student: Sarika
Enter the roll number of student: 10
Enter the marks of student: 55
Enter the grade of student: B+

{4: ['Sushma', 56, 'C'], 3: ['Sanjana', 76, 'B+'], 45: ['Manika', 45, 'D'], 1: ['Mitanshu', 23, 'F'], 7: ['Anshika', 77, 'B'], 9: ['Purva', 99, 'A+'], 2: ['Priyanka', 89, 'A'], 6: ['Anand', 100, 'A+'], 10: ['Sarika', 55, 'B+']}

Answered By

3 Likes


Related Questions