Page 380 - Computer Science Class 11 Without Functions
P. 380

while True:

                 key = int(input('Enter the number to be searched:'))
                 found = False

                 for index in range(len(myTuple)):
                     if myTuple[index] == key:
                         found = True
                         break

                 if found:
                     print(key,' is present in the tuple at index', index)
                 else:

                     print(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 18

        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. '''
             Objective: To display the names of students who have marks above 75
             Input: studentData

             Output: names of students who have marks>75
             '''
             studentData = {}

             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
             print(studentData)

             print("The names of students who have scored more than 75 marks are :")
             for D in studentData:

              if studentData[D][1] > 75:
                print(studentData[D][0])


         378   Touchpad Computer Science-XI
   375   376   377   378   379   380   381   382   383   384   385