CBSE Class 12 Computer Science Question 83 of 103

Working with Functions — Question 16

Back to all questions
16
Question

Question 12(a)

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)
  1. 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)