Write a function, add that takes two numbers and returns their sum.
Write a function that takes three numbers and returns their sum.
Restriction: You cannot use + inside this function's body
Hint: You can use add, the function you defined above
ⓘ
Write a function that takes a positive integer, i and returns a dictionary that maps
integers from 1 to i. Each integer is going to map itself. Example:
>>> create_dict(3)
{1: 1, 2: 2, 3: 3}
>>> create_dict(1)
{1: 1}
ⓘ
Write a function that takes two positive integers, n and m, and returns sum of all numbers
between 1 and n that are fully divisible by m. Example:
>>> sum_of_divisibles(6, 3)
9
>>> sum_of_divisibles(10, 4)
12
ⓘ
Write a function that takes a list of integers, t, it returns sum of all integers and deletes all
elements from t.
>>> a = [4, 3, 1, 2, 5, 2]
>>> d = get_sum(a)
>>> d
17
>>> a
[]
ⓘ
Write a function that takes two lists of numbers (with the same length), t1 and t2,
and returns a new list which item of index i is sum of t1[i] and t2[i].
Example:
>>> add_lists([1, 2, 3], [1, 3, 1])
[2, 5, 4]
ⓘ
Complete execution flow of the following program
def histogram(s): d = {} for c in s: d[c] = d.get(c, 0) + 1 return d h = histogram('oob')
Write a function, pow, which takes two numbers as arguments, x and y and returns x to the power of y
Write a function, multiply, which takes two numbers as arguments, a and b and returns their product.
Write a function, that takes two numbers, num1 and num2,
and returns (num1 ** num2) * num2.
Restrictions:
- You cannot use ** or * inside this function's body
- You should use pow to calculate num1 ** num2 and multiply to calculate result of
power * num2.
ⓘ
Write a function that takes a list and returns a new list which is reverse of the input list.
>>> a = [4, 3, 1, 2]
>>> d = reverse_list(a)
[2, 1, 3, 4]
ⓘ
Write a function that takes a dictionary and returns sum of all integers (whether they are
keys or values).
Example:
>>> get_sum({1: 'a', 2: 6, 12: 'po', 'jo': 4})
25
ⓘ
Complete execution flow of the following program
def double(a): return a + a def sub(x, y): return x - y def calculate(m, n): return double(sub(m, n) + sub(m, n)) print(calculate(2, 1))
4 >>>