CBSE Class 12 Computer Science Question 51 of 101

Functions — Question 19

Back to all questions
19
Question

Question 16(a)

Find the errors in the 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)