Define a function, middle_of_three, that takes three numbers, x, y and z,
and returns the number that is neither the largest nor the smallest (the middle value) .
Write a function that takes no arguments and prints numbers from 0 to 50 (including both), each in a new line.
Suppose the cover price of a book is $24.95, but bookstores get a 40% discount. Shipping costs $3 for the first copy and 75 cents for each additional copy. What is the total whole sale cost for 60 copies?
Write a function that takes an integer as argument and:
- It returns 'both' if it is divisible by 17 and 19
- It returns 'seventeen' if it is divisible by 17
- It returns 'nineteen' if it is divisible by 19
- It returns 'neither' otherwise.
Complete execution flow of the following program
def power(a): while True: a = a ** 2 if a > 100: break return a res = power(5)
Complete execution flow of the following program
def add(n, m): total = 0 while True: if total > 20: break total = total + n + m return total res = add(8, 8)
def power(n):
total = 0
while True:
total = total + n
print('pse')
break
return total
print('ani')
res = power(10)
Given the above script:
| What is the value of res: | ||
| What is the printed value: |
def compare(a, b, c):
print(a == b or a < c)
x, y, z = 1, 2, 3
d = x == 1 or y == 2 or y < z
compare(x, y, -1 * z)
Given the above script:
| What is printed: | ||
| What is the final value of d: |
Complete execution flow of the following program
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"
>>> "Invalid" >>> "Coat" >>>
Complete execution flow of the following program
def add(a, b): print(a + b ** b) def sub(x, y): print(x - y) add(x + x, x + y) sub(1, 2)
-1 29 >>>