Computer Science
Find the errors in code given below :
def minus(total, decrement)
output = total - decrement
print(output)
return (output)
Answer
The errors in the code are:
def minus(total, decrement) # Error 1
output = total - decrement
print(output)
return (output)
- There should be a colon at the end of the function definition line.
The corrected code is given below:
def minus(total, decrement):
output = total - decrement
print(output)
return (output)
Related Questions
Consider the code below and answer the questions that follow :
def multiply(number1, number2): answer = number1 * number2 print(number1, 'times', number2, '=', answer) return(answer) output = multiply(5, 5)
(i) When the code above is executed, what prints out ?
(ii) What is variable output equal to after the code is executed ?
Consider the code below and answer the questions that follow :
def multiply(number1, number2): answer = number1 * number2 return(answer) print(number1, 'times', number2, '=', answer) output = multiply(5, 5)
(i) When the code above is executed, what gets printed ?
(ii) What is variable output equal to after the code is executed ?
Find the errors in code given below :
define check() N = input ('Enter N: ') i = 3 answer = 1 + i ** 4 / N Return answer
Find the errors in code given below :
def alpha (n, string = 'xyz', k = 10) : return beta(string) return n def beta (string) return string == str(n) print(alpha("Valentine's Day"):) print(beta(string = 'true')) print(alpha(n = 5, "Good-bye"):)