write a program to enter names of employees and their salaries as input by user and store them in a dictionary 'EMP'
Answers
Answer:
Hey this is in python...
emp = { }
num = int(input("How many employees? "))
for i in range(num):
name = input("Enter name: ")
sal = float(input("Enter Salary: "))
emp[name] = sal
print(emp)
# HOPE THIS HELPS!!
Answer:
EMP = {}
while True:
name = input("Enter employee name (or 'q' to quit): ")
if name == 'q':
break
salary = input("Enter employee salary: ")
EMP[name] = salary
print(EMP)
Explanation:
This program uses a while loop to repeatedly prompt the user to enter an employee name and salary. Inside the loop, the user's input is stored in the dictionary "EMP" as key-value pair where key is employee name and value is salary . The loop continues until the user enters 'q' to quit. After the loop, the program prints out the contents of the dictionary 'EMP' so that the user can see the stored data.
Note that this program is just an example, and it will not check the salary entered is a number or not, it takes input as string. you can add more validation or error handling as per the requirement.
More question and answers:
https://brainly.in/question/54822812
https://brainly.in/question/54823978
#SPJ3