- Here ,We are going to create a dictionary with roll number, name and marks of n students in a class and display the names of students who have scored marks above 75 in python. We can use for loop to enter number of students in dictionary. With the help of if else loop,we can check the number of students who got more than 75 percentage marks .
Python program to create dictionary
# Python Program to find Student Grade
n = int(input("Enter number of students :"))
result = {}
for i in range(n):
print("Enter Details of students :",i+1)
rno = int(input("Roll number :"))
name = input("Name :")
english = float(input("Enter English Marks: "))
math = float(input("Enter Math score: "))
computers = float(input("Enter Computer Marks: "))
physics = float(input("Enter Physics Marks: "))
chemistry = float(input("Enter Chemistry Marks: "))
total = english + math + computers + physics + chemistry
percentage = (total / 500) * 100
result[rno] = [name,percentage]
print(result)
for s in result:
if result[s][1]>75:
print("Following students having more than 75 marks:")
print(result[s][0])
Output:
Enter number of students :3 Enter Details of students : 1 Roll number :3 Name :Sumedh Enter English Marks: 77 Enter Math score: 88 Enter Computer Marks: 99 Enter Physics Marks: 67 Enter Chemistry Marks: 56 Enter Details of students : 2 Roll number :2 Name :Sushil Enter English Marks: 78 Enter Math score: 55 Enter Computer Marks: 66 Enter Physics Marks: 44 Enter Chemistry Marks: 77 Enter Details of students : 3 Roll number :8 Name :Anita Enter English Marks: 66 Enter Math score: 22 Enter Computer Marks: 11 Enter Physics Marks: 44 Enter Chemistry Marks: 33 {3: ['Sumedh', 77.4], 2: ['Sushil', 64.0], 8: ['Anita', 35.199999999999996]} Following students having more than 75 marks: Sumedh
Python programs with solutions
- To calculate profit loss for a given cost and sale price
- To calculate EMI for amount, period and interest
- To calculate tax-GST/ income tax
- To find the largest and smallest numbers in a list
- To find third largest/ smallest number in a list
- To find sum of squares of the first hundred natural numbers
<