1.Use a for loop and the list append method to generate the powers of 2 to produce the following result [1, 2, 4, 8, 16, 32, 64, 128]
2.Write a for loop that prints a dictionary's items in sorted (ascending) order
1
Expert's answer
2021-05-01T14:11:54-0400
def power_of_2(n=8):
power_2 = list()
for i in range(n):
power_2.append(2**i)
return power_2
def print_dict(dict_1):
for el in sorted(dict_1.values()):
print(el)
print(power_of_2())
print_dict({1: 1, 2: 9, 3: 4})
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment