You're building a wall. Each brick is 20cm tall.
You want to build a wall of a certain height in meters.
Write a function that takes one argument, the height in meters,
and returns how many bricks you need.
Example:
>>> bricks_needed(1)
5.0
>>> time_to_print(3)
15.0
Write a function that takes one string as argument and inside a for loop print every
vowel that appears in the string, each in a new line. (vowels in english are a, e, i, o, u).
Example:
>>> print_vowels('something')
o
e
i
Write a function, countup, that takes one positive integer, n,
and inside a while True it prints numbers from 1 up to and including n, one per line.
End with printing "Done!".
Example:
>>> countup(3)
1
2
3
Done!
Write a function named calculate that takes two numbers as arguments, a abd b, and returns a to the power of a minus b.
Write a function, perform named that takes two numbers as arguments, x and y, and returns x divided by y times x.
Call perform and assign its return value to m
Call calculate passing m and 5 as arguments
Define a function, min_of_three, that takes three numbers, x, y and z,
and returns the smallest of the three numbers.
Restriction: You cannot use max or min functions.
Complete execution flow of the following program
a = 2.25 x = 1.25 while True: print(x) y = (x + a/x) / 2 if y == x: break x = y
def clothing_recommendation(temperature, is_raining):
if temperature < -50 or temperature > 60:
return "Invalid"
elif temperature >= 25:
if is_raining == "yes":
return "Light clothes and umbrella"
else:
return "Light clothes"
elif 15 <= temperature <= 24:
return "Jacket"
else:
return "Coat"
Given the above script, what are the results of the following calls:
| clothing_recommendation(25, "no"): | ||
| clothing_recommendation(25, "yes"): | ||
| clothing_recommendation(24, "yes"): |
def rect_area(l, w):
return l * w
def square_area(s):
return rect_area(s, s)
a = square_area(5)
print(a)
In the above example:
| What is the printed value: |
Complete execution flow of the following program
def print_true(): print(True) def print_value(v): print(v) value = True print_value(False) print_true() print_value(value)
Complete execution flow of the following program
def compare(a): print_arg(a == 0 or a == 1) print_arg(a < 0 or a > 10) def print_arg(x): print(x) compare(4)
False False >>>