1. When does a function execute?
2. What's the output of the following Python program:
def one(x):
x += 1
print(x)
y = 17
one(y)
print(y)
3. What's the error in the following function:
def one(x):
print(x)
print(x)
4. What's the output for the following function:
def one(x):
x += 1
return x
y = 17
y = one(y)
print(y)
5. What's the output for the following function:
def two(x):
y = x
x += 1
return x, y
x, y = two(100)
print(x, y)
6. What's the output for the following function:
def two(a, b):
return a + b
sum = two(1, 9)
print(sum)
7. What's the output for the following function:
def two(a, b):
return a + b
sum = two('1', "9")
print(sum)
8. What's the output for the following function:
def two(a, b):
return a / b
answer = two(9, 2)
print(answer)
9. What's the output for the following function
(Notice the two front slashes}:
def two(a, b):
return a // b
answer = two(9, 2)
print(answer)
10. The following function returns the square of it's parameters;
write a function that returns the cube of it's parameter:
def square(x):
return x**2
y = square(10)
print(y)