Page 513 - Computer Science V2.0 Class 11
P. 513
found, index = search(myTuple, key)
if found:
print("Element",key," is present in the tuple at index ", index)
else:
print("Element",key," is not present in the tuple")
searchAgain = input("Continue another search? say Y/y for yes, N/n for no:")
if searchAgain != "Y" and searchAgain != "y":
break
Program 17: Write a program that accepts student data, stores it in a dictionary, and then searches for and displays
the names of students who have scored more than 75 marks.
Ans. studentData = {}
def acceptData():
'''
Objective : To input student details
Input Parameter : None
Return Value : None
'''
ch = 'y'
while ch == 'y':
rollNo = input("Enter Roll No : ")
name = input("Enter Name : ")
marks = int(input("Enter Marks : "))
studentData[rollNo] = [name, marks]
ch = input("Do you wish to enter more : ")
if ch != 'y':
break
def searchRecords ():
'''
Objective : To search for students scoring >75
Input Parameter : None
Return Value : None
'''
print("The names of students who have scored more than 75 marks are :")
for rollNum in studentData:
if studentData[rollNum][1] > 75:
print(studentData[rollNum][0])
acceptData()
print("The data in dictionary is : ")
print(studentData)
searchRecords()
Practical 499

