Page 58 - Modular v1.1 Pyhton
P. 58

E.  Long answer type questions.

                      1.   Write the components of a function.
                      2.   How can we call a function in Python? Explain using an example.
                      3.   What are the different types of functions? Explain in detail.

                      4.   What are the different steps to create a function? Explain in detail.
                                                                                                  Critical Thinking
                  F.  What will be the output of the following codes?

                      1.   def f(x):
                               y = x**x
                               return y
                           print ("testing...")
                           print ("passing the value 4")
                           z = f(2)
                           print ("the function returns", z)
                      2.  def power(x, n):
                               result = 1
                              for i in range (n):
                                   result *=x
                               return result
                           a = int (input ("Enter number"))
                           b = int (input ("Raise to power"))
                           pw = power (a, b)
                           print(a, "raise to power", b, "is", pw)





                                                    In the lab                                  Subject Enrichment


                     Write a program using functions to:

                     1.  check whether the input number is even or odd.
                     2.  print a string 'orange' by calling a function.





                   Teacher's Corner

                  1.   Demonstration of creating functions to the students.
                  2.   Discuss different types of functions with the students.












                   56     Touchpad MODULAR (Version 1.0)
   53   54   55   56   57   58   59   60   61   62   63