Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chornyi Vitalii #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions python_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
The function should return the sum of the values of the dictionary
"""
# Write your sum_values function here:
# ======================================
# def sum_values(my_dictionary):
# sum = 0
# for value in my_dictionary.values():
# sum += value
# return sum

# print(sum_values({"milk":5, "eggs":2, "flour": 3}))
# ========================================
# Uncomment these function calls to test your sum_values function:
# print(sum_values({"milk":5, "eggs":2, "flour": 3}))
# should print 10
Expand All @@ -20,7 +28,16 @@


# Write your sum_even_keys function here:
# =========================================
# def sum_even_keys(my_dictionary):
# sum = 0
# for num in my_dictionary.keys():
# if num % 2 == 0:
# sum += my_dictionary[num]
# return sum

# print(sum_even_keys({1:5, 2:2, 3:3}))
# ===========================================
# Uncomment these function calls to test your function:
# print(sum_even_keys({1:5, 2:2, 3:3}))
# should print 2
Expand All @@ -34,7 +51,14 @@
The function should add 10 to every value in my_dictionary and return my_dictionary
"""
# Write your add_ten function here:
# ===================================
# def add_ten(my_dictionary):
# for num in my_dictionary.keys():
# my_dictionary[num] += 10
# return my_dictionary

# print(add_ten({1:5, 2:2, 3:3}))
# =====================================
# Uncomment these function calls to test your function:
# print(add_ten({1:5, 2:2, 3:3}))
# should print {1:15, 2:12, 3:13}
Expand All @@ -48,7 +72,16 @@
This function should return a list of all values in the dictionary that are also keys.
"""
# Write your values_that_are_keys function here:
# =============================================
# def values_that_are_keys(my_dictionary):
# keys = []
# for key in my_dictionary.values():
# if key in my_dictionary.keys():
# keys.append(key)
# return keys

# print(values_that_are_keys({1:100, 2:1, 3:4, 4:10}))
# ===============================================
# Uncomment these function calls to test your function:
# print(values_that_are_keys({1:100, 2:1, 3:4, 4:10}))
# should print [1, 4]
Expand Down