Try to solve each problem on paper first before using Thonny to confirm your answers.
[PP Problem 2.1] Indicate whether the result is an int or float by (not) including a decimal point, e.g. 5 for an int, 5.0 for a float.
For each of the following expressions, what value will the expression give?
a. 9 - 3
b. 8 * 2.5
c. 9 / 2
d. 9 / -2
e. 9 // -2
f. 9 % 2
g. 9.0 % 2
h. 9 % 2.0
k. 9 / -2.0
l. 4 + 3 * 5
m. (4 + 3) * 5
Write a function named average
that has two numbers as parameters and
returns the average of those values.
Given variables x
and y
, which are assigned the values 3 and 12.5,
respectively, what will the following expression print?
a. print("The rabbit is " + str(x) + ".")
b. print("The rabbit is " + str(x) + " years old.")
c. print(str(y) + " is average.")
d. print(str(y) + " * " + str(x))
e. print(str(y) + " * " + str(x) + " is " + x*y + ".")