Q. Write a program to enter names of employees and their salaries as input and store them in a dictionary.

 

Answer = 

 

dic = { }
while True :
      name = input("Enter employee name :-")
      sl = int(input("Enter employee salary :-"))
      dic[ name] = sl
      user = input("Do you want to quit then enter yes :-")
      if user == "yes" :
            break
print(dic)


Output :-

Enter employee name :-Path
Enter employee salary :-1000
Do you want to quit then enter yes :-no
Enter employee name :-Walla
Enter employee salary :-2000
Do you want to quit then enter yes :-no
Enter employee name :-PW
Enter employee salary :-10000
Do you want to quit then enter yes :-yes
{'Path': 1000, 'Walla': 2000, 'PW': 10000}

>>>

20 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post