Programming Examples
Create a dictionary with RollNo and Percentage of 10 students. Write a program to print only those RollNo from the dictionary where percentage is greater than 50.
Create a dictionary with RollNo and Percentage of 10 students. Write a program to print only those RollNo from the dictionary where percentage is greater than 50.
Solution# Dictionary with RollNo as key and Percentage as value
students = {
101: 45,
102: 67,
103: 52,
104: 38,
105: 75,
106: 49,
107: 81,
108: 55,
109: 30,
110: 60
}
print("Roll numbers with percentage greater than 50:")
for rollno, percentage in students.items():
if percentage > 50:
print(rollno)
▶ RUN Output/ Explanation: Roll numbers with percentage greater than 50:
102
103
105
107
108
110