Thursday, 15 February 2024

Class 11 CS Practical - 48

 

48 - WAP in Python to create a dictionary with name of employee, their salary and access them.


Emp={}

c='y'

while c in 'yY':

    name=input("Enter the name of employee: ")

    salary=float(input("Enter the salary of employee: "))

    Emp[name]=salary

    c=input("Do you want to add more emp(y/n): ")

print("Details of Employee:")

print(Emp)

Output:

Enter the name of employee: Ram

Enter the salary of employee: 38545

Do you want to add more emp(y/n): y

Enter the name of employee: Raj

Enter the salary of employee: 45854

Do you want to add more emp(y/n): y

Enter the name of employee: Aman

Enter the salary of employee: 47825

Do you want to add more emp(y/n): n

Details of Employee:

{'Ram': 38545.0, 'Raj': 45854.0, 'Aman': 47825.0}


No comments:

Post a Comment