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


You can understand by Watching video :-



Answer :-

Yes, We can store these Data by following program :-

dic = { }
while True  :
    roll = input("Enter the roll no. of student (enter Q for quit )= ")
    if roll == "Q" or roll == "q" :
        print()
        break
    else :
        name = input("Enter the name of student  = ")
        mark = input("Enter the marks of student = ")
        grade = input("Enter the grade of student = ")
        dic[roll] = [ name , mark , grade ]
        print()
print("All Data :-",dic)

Output :-

Enter the roll no. of student (enter Q for quit )= 5
Enter the name of student  = Path
Enter the marks of student = 96
Enter the grade of student = A+

Enter the roll no. of student (enter Q for quit )= 9
Enter the name of student  = Walla
Enter the marks of student = 85
Enter the grade of student = A

Enter the roll no. of student (enter Q for quit )= 13
Enter the name of student  = Portal
Enter the marks of student = 95
Enter the grade of student = A+

Enter the roll no. of student (enter Q for quit )= 10
Enter the name of student  = Express
Enter the marks of student = 70
Enter the grade of student = C

Enter the roll no. of student (enter Q for quit )= q

All Data :- {'5': ['Path', '96', 'A+'], '9': ['Walla', '85', 'A'], '13': ['Portal', '95', 'A+'], '10': ['Express', '70', 'C']}

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post