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, add that takes two numbers and returns their sum.
Write a function that takes three numbers and returns their sum.
Restriction: You cannot use + inside this function's body
Hint: You can use add, the function you defined above
Write a function, add that takes two numbers and returns their sum.
Write a function, average that takes three numbers and returns their average.
Restriction: You cannot use + inside this function's body
Define a function, are_equal, which takes two values, and returns True if they are equal, False otherwise.
Define a function, get_count, which takes one word and one character, s and char,
and returns how many times char appears in s,
till it becomes char. Example:
>>> get_count('abaa', 'a')
3
>>> get_count('abaa', 'b')
1
>>>
Restrictions:
- You cannot use == or !=
- You cannot use method count of strings
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 power, that takes two integers, a and b, and returns a to the power of b.
Write a function product, that takes two integers, a and b, and returns their product.
Write a function divisible, that takes two integers, x and y, and returns True if x is fully divisible by y, and False otherwise.
Write a function calculate, that takes two integer, n and m and:
- It returns n to the power of m if n is even and m is odd.
- It returns m to the power of n if n is odd and m is even.
- It returns their product otherwise.
Restriction: You CANNOT use modulus (%) or any relational operator (<, >, !=, ...)
inside this function's body.
def divisible(n, m):
if n % m == 0:
return 1
return 2
def get_sum(x):
total = 0
for i in range(x):
if total == 3:
print(total)
total = 0
total = total + divisible(i, 3)
return total
res = get_sum(3)
Given the above script:
| What is the value of res: | ||
| What is the printed value: |
def quotient(x):
return x // 2
def remainder(x):
return x % 2
def add(x):
return quotient(x) + remainder(x)
Given the script above, what is the return value of the following expressions:
| add(2): | ||
| add(5): | ||
| add(13): |
Complete execution flow of the following program
def quotient(x): return x // 2 def remainder(x): return x % 2 def add(x): return quotient(x) + remainder(x)
>>> add(7) 4 >>> add(10) 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 >>>