Write a function, multiply that takes two numbers and returns their product.
Write a function that takes three numbers and returns their product.
Restriction: You cannot use * inside this function's body
Hint: You can use multiply, the function you defined above
Complete execution flow of the following program
def is_vowel(char): for vowel in 'aeiou': if char == vowel: return 1 return 0 def count_vowels(s): count = 0 for char in s: count = count + is_vowel(char) if char == 'y': print('reset') count = 0 return count res = count_vowels('bye')
reset >>>
Write a function, final_score(a: int, b: int, c: int), that takes three test scores and returns final score, which is the sum of average three test score and the bonus. The bonus should be calculated as follows:
- if average score is above 80, student gets 5 bonus points
- if average score is between 50 and 80 (including both), student gets 2 bonus points
- if average score is below 50 student doesn't get any bonus point
Write a function, mean that takes two numbers and returns their mean.
Example:
>>> mean(3, 5)
4.0
Write a function, square that takes a number and returns its square.
Example:
>>> square(3)
9
Write a function, square_of_mean, that takes two numbers and returns square of their mean.
Example:
>>> square_of_mean(4, 6)
25.0
Restriction: You cannot use *. + or / inside this function's body
Write a function that takes two positive integers, n and m, and returns sum of all numbers
between 1 and n that are fully divisible by m. Example:
>>> sum_of_divisibles(6, 3)
9
>>> sum_of_divisibles(10, 4)
12
A taxi charges:
- $4 for the first km
- $2 for each km from 2 to 10
- $1.50 for each km beyond 10
Write a function that takes the number of kilometers traveled and returns the total fare. Example:
>>> taxi_meter(1)
4
>>> taxi_meter(2)
6
>>> taxi_meter(10)
22
>>> taxi_meter(15)
29.5
def power(a, b):
return a ** b
def multiply(a):
return a * a
def calculate(a, b):
if power(a, b) == multiply(a):
return power(a, b) + multiply(a)
elif multiply(a) == multiply(b):
return multiply(a - b)
return multiply(a) == power(a, b)
Given the above script, what are the results of the following calls:
| calculate(3, 3): | ||
| calculate(3, 4): | ||
| calculate(3, 2): |
def a(x):
return x % 3 == 0
def b(w, y):
if w == y:
return True
return False
def ani(x, y):
if not b(x, y):
return a(x)
elif b(x, y) and not a(x):
return 'jo more'
return b(x, y)
ani(3, 3)
ani(5, 5)
Given the above script, what are the results of the following calls:
| ani(3, 3): | ||
| ani(5, 5): |
Complete execution flow of the following program
def quotient(x, y): return x // y def remainder(x, y): return x % y def add(x, y): return quotient(x, remainder(x, y))
>>> add(4, 3) 4 >>> add(8, 3) 4 >>>
Complete execution flow of the following program
def power(a, b): return a ** b def multiply(a): return a * a def calculate(a, b): if power(a, b) == multiply(a): return power(a, b) + multiply(a) elif multiply(a) == multiply(b): return multiply(a - b) return multiply(a) == power(a, b) a = calculate(2, 1) calculate(4, 4)