You are on page 1of 2

7.

Write a program to create a student dictionary containing the name (key) and marks (value) of 5
student taken whose marks is greater than 80. If not display appropriate message.

The Code is:

sd={}

for i in range(5):

stu_name=input("Enter the name of the student:")

mrks=int(input("Enter marks:"))

sd[stu_name]=mrks

print("The dictionary is",sd)

for i in sd:

if sd[i]>80:

print("Student whose marks are more than 80:",i)

else:

print("There are no such student whose marks are greater than 80")

Output-
Enter the name of the student:Abhijit

Enter marks:70

Enter the name of the student:Ram

Enter marks:85

Enter the name of the student:Ankit

Enter marks:76

Enter the name of the student:Aditya

Enter marks:90

Enter the name of the student:Arjun

Enter marks:85

The dictionary is {'Abhijit': 70, 'Ram': 85, 'Ankit': 76, 'Aditya': 90, 'Arjun': 85}

There are no such student whose marks are greater than 80

Student whose marks are more than 80: Ram

There are no such student whose marks are greater than 80

Student whose marks are more than 80: Aditya

Student whose marks are more than 80: Arjun

You might also like