Computer Science, asked by narasimhasistla1979, 8 months ago

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.

Answers

Answered by Equestriadash
18

n = int(input("Enter the number of students: "))

stud_dict = dict()

print()

for i in range(n):

   rn = int(input("Enter the roll number: "))

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

   m = float(input("Enter the marks obtained: "))

   stud_dict[rn] = name, m

   print()

print()

print("Your given dictionary: ")

print()

print("Roll Number\t", "Name\t", "Marks")

print()

for i in stud_dict:

   print(i, "\t\t", stud_dict[i][0], "\t\t", stud_dict[i][1])

print()

print("Students with marks above 75: ")

print()

for i in stud_dict:

   if stud_dict[i][1] >= 75:

       print(i, "\t", stud_dict[i][0], "\t", stud_dict[i][1])

Answered by kunjika158
1

Source Code :

n=int(int(input("Enter n: ")))

d={}

for i in range(n):

roll_no=int(input("Enter roll no: "))

name=input("Enter name: ")

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

d[roll_no]=[name,marks]

for k in d:

if(d[k][1]>75):

print(d[k][0])

Output :

Enter n: 2

Enter roll no: 1

Enter name: a

Enter marks: 85

Enter roll no: 2

Enter name: b

Enter marks: 55

Hope it helps you !!

Similar questions