Computer Science, asked by samaksh225, 11 months ago

Python- wap to create a dictionary of winners of competition with their names as key and number of wins as value. Also check whether a given value (no. Of wins) is present in that dictionary or not.

Answers

Answered by manavjaison
22

Heya friend,

Here we go:

                       SOURCE CODE

# to create a dictionary of competition winners with their names and number of wins and check a value in the dictionary

d={}

n=int(input('Enter number of the winners :'))

for i in range (n):

   a=input('Enter name of the winner:')

   b=int(input('Enter the number of wins of the winner:'))

   d[a]=b

print('\n')

print('name of the winners','\t','number of wins')

for i in d:

   print(i,'\t','\t','\t',d[i])

print('\n')

val=int(input('Enter the value to be checked:'))

for i in (d.values()):

   if val==i:

       print('found')

       break

else:

   print('not found')

                            OUTPUT

Enter number of the winners : 3

Enter name of the winner: Manav1

Enter the number of wins of the winner: 12

Enter name of the winner: Manav2

Enter the number of wins of the winner: 13

Enter name of the winner: Manav3

Enter the number of wins of the winner: 14

name of the winners   number of wins

Manav1                12

Manav2        13

Manav3                14

Enter the value to be checked: 14

found

>>>

Thanks !

#BAL #answerwithquality

@MANAV

 

       

Similar questions