Check sibling questions

What will be the output of the following program.?

(a) 1       def increase (x):      (b) a=1

     2          a=a+x                      def f():

     3          return                          a=10

     4                                          print(a)

     5      a=20

     6    b=5

     7    increase (b)

     8    print(a) 

 

 

Answer:

(a)

This code gives an error as there is no value assigned to ‘a’ in the function ‘increase( )’.

(b)

The code gives an output 1 .

  1. Computer Science - Class 12
  2. Chapter 14 - Functions in python

About the Author

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo