Create a dictionary with the roll number, name and marks of n students in a class and display the names of students who have scored marks above 75.

Create a dictionary with the roll number, name and marks of n students in a class and display the names of students who have scored marks above 75.

 

Program

no_of_std = int(input("Enter number of students: "))  

result = {}  

for i in range(no_of_std):  

   print("Enter Details of student No.", i+1)  

   roll_no = int(input("Roll No: "))  

   std_name = input("Student Name: ")  

   marks = int(input("Marks: "))  

   result[roll_no] = [std_name, marks]    

print(result)  

# Display names of students who have got marks more than 75  

for student in result:  

   if result[student][1] > 75:  

       print("Student's name who get more than 75 marks is/are",(result[student][0]))
       

 

Output:

Enter number of students: 5
('Enter Details of student No.', 1)
Roll No: 1
Student Name: "Amit"
Marks: 78
('Enter Details of student No.', 2)
Roll No: 2
Student Name: "Abhay"
Marks: 78
('Enter Details of student No.', 3)
Roll No: 3
Student Name: "Pooja"
Marks: 76
('Enter Details of student No.', 4)
Roll No: 4
Student Name: "Aarti"
Marks: 60
('Enter Details of student No.', 5)
Roll No: 5
Student Name: "Harshit"
Marks: 55
{1: ['Amit', 78], 2: ['Abhay', 78], 3: ['Pooja', 76], 4: ['Aarti', 60], 5: ['Harshit', 55]}
("Student's name who get more than 75 marks is/are", 'Amit')
("Student's name who get more than 75 marks is/are", 'Abhay')
("Student's name who get more than 75 marks is/are", 'Pooja')
>>> 

 

Also Check :

Leave a Reply

Your email address will not be published. Required fields are marked *