Write a program to create a dictionary
Employee= {‘name’: “Pulkit”, ‘age’: 16, ‘salary’: 50000}
1. Add department Employee[‘dept’]=’Sales’
2. Print all keys.
3. Print all values.
4. Delete Employee[‘age’]=16
5. Check ‘age’ in Employee
6. Calculate Length of the dictionary
7. Use Clear method
Answers
Answered by
1
Employee = {"name": "Pulkit", "age": 16, "salary": 50000}
print("keys:", list(Employee.keys()))
print("values:", list(Employee.values()))
del Employee["age"]
print("age" in Employee)
print("Length:", len(Employee))
Employee.clear()
print(Employee)
Answered by
0
Answer:
Employee = {"name": "Pulkit", "age": 16, "salary": 50000}
print("keys:", list(Employee.keys()))
print("values:", list(Employee.values()))
del Employee["age"]
print("age" in Employee)
print("Length:", len(Employee))
Employee.clear()
print(Employee)
Similar questions