Page 126 - TrackpadV5.1_class8
P. 126

4.  Answer in one or two words.
                      a.  Name the term used to access list items in Python.                          _______________
                      b.  Which bracket is used to enclose index numbers in Python?                   _______________

                      c.  What are the input values passed to a function called?                      _______________
                      d.  What separates parameters in a function definition?                         _______________
                      e.  Name the function in Python that can add multiple elements to a list.       _______________

                  5.  Think and answer.
                      a.  What are functions in Python? What are the key components of a Python function?
                         ______________________________________________________________________________

                         ______________________________________________________________________________
                      b.  Explain the difference between built-in functions and user-defined functions.

                         ______________________________________________________________________________
                         ______________________________________________________________________________

                      c.  Describe the use of escape sequences in Python strings.
                         ______________________________________________________________________________

                         ______________________________________________________________________________
                      d.  What is the purpose of the return statement in a function?

                         ______________________________________________________________________________
                         ______________________________________________________________________________
                      e.  Define the following functions:

                         (i) upper()
                         ___________________________________________________________________________

                         (ii) capitalize()
                         ___________________________________________________________________________
                  6.  Find the output of the following Python code:

                      a.  def greet():                                       b.  def add(a, b):
                             print("Hello, World!")                                return a + b
                         greet()                                                result = add(3, 5)
                         ______________________                                 print(result)
                                                                                 ______________________
                      c.  s = "Python"                                       d.  list = [1, 2, 3]
                         print(s.lower())                                       list.append(4)
                         ______________________                                 print(list)

                                                                                 ______________________
                      e.  s = "hello"                                         f. def multiply(x, y=2):

                         s = s.capitalize()                                         return x * y
                         print(s)                                               print(multiply(3))
                         ______________________                                 ______________________




                  124   Pro (V5.1)-VIII
   121   122   123   124   125   126   127   128   129   130   131