Write a function, temperature_status(temp: float),
that returns the condition of the fridge based on its current temperature:
- 0 - 4 (excluding 4) -> "too cold"
- 4 - 7 (excluding 7) -> "optimal"
- 7+ -> "too warm"
Example:
>>> temperature_status(2.0)
'too cold'
>>> temperature_status(5.0)
'optimal'
>>> temperature_status(9.5)
'too warm'
Complete execution flow of the following program
def power(a): while True: a = a ** 2 if a > 100: break return a res = power(5)
Write a function that takes an integer as argument and:
- It returns 'positive' if it is positive
- It returns 'negative' if it is negative
- It returns 'neutral' if it is 0
Write a function, that takes one numbers as argument, and returns True if it is divisible by 5 but not divisible by 10, False otherwise.
Write a function, countup, that takes one positive integer, n,
and prints numbers from 1 up to and including n, one per line.
End with printing "Done!".
Example:
>>> countup(3)
1
2
3
Done!
Restriction: You cannot use for or if.
Write a function that takes two values and:
- It returns 'equal' if they are euqal
- It returns 'different' otherwise.
def do_smth_twice(a, b):
do_smth(a, a)
do_smth(a, b)
def do_smth(a, b):
print(a + b)
do_smth('ani', 'pse')
What is printed if we execute the above program?
def divide(n):
while True:
break
n = n / 2
print('done')
print('DONE')
return n
res = divide(4)
Given the above script:
| What is the value of res: | ||
| What is the printed value: |
Complete execution flow of the following program
def repeat_acting(): act() print("acting") def act(): print("acting") repeat_acting()
"acting" "acting" >>>
Complete execution flow of the following program
def pow(a, b): print(a ** b - b) def calculate(x, y): pow(x + y, x - y) a = 3 calculate(a, 2)
4 >>>