Please solve these problems in the empty cells provided after the problem.
Problem 1.1: Write a function double to doube given number.
>>> double(5)
10
What happens you pass a string as argument to this function? Try to understand why works that way.
# your code here
def double(x):
return x*x
# try for a sample input
double(5)
Problem 1.2: Write a function average that takes a list of numbers as argument and returns average of all those numbers.
>>> average([1, 2, 3, 4])
2.5
Hint: The built-in function sum can be used to compute sum of a list of numbers.
>>> sum([1, 2, 3, 4])
10
# your code here
def average(numbers):
return sum(numbers) / len(numbers)
# try it out
average([1, 2, 3, 4])