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

homework #7

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
46 changes: 46 additions & 0 deletions python5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
def sum_values(my_dictionary):

return sum(my_dictionary.values())


print(sum_values({10: 1, 100: 2, 1000: 3}))

def sum_even_keys(my_dictionary):
values = 0
for even in my_dictionary.values():
if even % 2 == 0:
values += even
return values




print(sum_even_keys({1: 5, 2: 2, 3: 3}))

def add_ten(my_dictionary):

for key, value in my_dictionary.items():
my_dictionary[key] = value + 10
return my_dictionary
print(add_ten({10:1, 100:2, 1000:3}))



def values_that_are_keys(my_dictionary):
list = []
for value in my_dictionary.values():
for key in my_dictionary.keys():
if key == value:
list.append(key)
return list
print(values_that_are_keys({1:100, 2:1, 3:4, 4:10}))


def max_key(my_dictionary):
maximum = max(my_dictionary.values())
for key in my_dictionary:
if my_dictionary[key] == maximum:
return key


print(max_key({1: 100, 2: 10000, 3: 4, 4: 1000000}))