Computer Science, asked by Malleshwarrao, 16 days ago

create a dictionary to enter roll number and marks of student and then ask the user enter roll number then search it and display mark of that student if he she present in the list​

Answers

Answered by Equestriadash
10

The following cσdes have been written using Python.

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

stud_dict = dict()

print()

for i in range(n):

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

   y = float(input("Enter the marks secured: "))

   stud_dict[x] = y

   print()

print()

cn = int(input("Enter the roll number of the student whose marks you'd like to view: "))

if cn in stud_dict.keys():

   print(stud_dict[cn], "marks have been secured by roll number", str(cn) + ".")

else:

   print("No such student/roll number.")

Similar questions