Write a program to create a dictionary with the roll number,
name and marks of n students in a class and display the names of students who
have marks above 75.
Solution :
Also Check
Source Code
n = int(input("How many Students?"))
stu = {}
for i in range(1, n+1):
print("Enter details of Student", (i))
rollno= int(input("Roll number :"))
name = input("Name :")
marks = float(input("Marks :"))
d = {"Roll_no" : rollno, "Name": name, "Marks": marks}
key = "Stu" + str(i)
stu[key] = d
print("Students with marks > 75 are:")
for i in range(1, n+1):
key = "Stu" + str(i)
if stu[key]["Marks"] >= 75:
print(stu[key])
Output
Sample Output:
How many Students?3
Enter details of Student 1
Roll number :01
Name :Raja
Marks :57
Enter details of Student 2
Roll number :02
Name :Sanjay
Marks :78
Enter details of Student 3
Roll number :03
Name :Devi
Marks :79
Students with marks > 75 are:
{'Roll_no': 2, 'Name': 'Sanjay', 'Marks': 78.0}
{'Roll_no': 3, 'Name': 'Devi', 'Marks': 79.0}
>>>