Computer Science, asked by vedavathir29, 1 month ago

Python program to Create a dictionary of employees to store names and sales made in 5 different months.. Find total sales using for loop to traverse through the dictionary. ​

Answers

Answered by KesavanCSE
2

Answer:

employee = {'month1': 100,"month2": 200,"month3": 300,"month4": 400,"month5":500 }

sum=0

for i in employee.values():

sum+=i

print(sum)

Explanation:

output : 1500

Answered by chitrarameshram24
1

Answer:

Creating a dictionary is as simple as placing items inside curly braces {}separated by commas. An item has a key and a corresponding value that is expressed as a pair (key: value). While the values can be of any data type and can repeat, keys must be of immutable type (string, number or tuple with immutable elements) and must be unique. As you can see from above, we can also create a dictionary using the built-in dict()function.

While indexing is used with other data types to access values, a dictionary uses keys. Keys can be used either inside square brackets [] or with the get()method. If we use the square brackets [], Key Error is raised in case a key is not found in the dictionary. On the other hand, the get() method returns None if the key is not found. Output

Similar questions