Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 105 - 2612_Digimind
P. 105

    1.  Tick ( ) the correct option.

                        a.   Aarav is writing a Python program and wants to display a message on the screen using a function
                            that is already built into Python. Which function should he use?

                             (i)  custom_function()                           (ii)  print()
                            (iii)   my_function()                            (iv)  user_function()
                        b.   Meera wants to create her own function in Python to perform a specific task. She needs to follow
                            the correct syntax while defining the function. Which of the following shows the correct way to
                            define a function in Python?
                             (i)  function my_function()                      (ii)  def my_function[]

                            (iii)  define my_function():                     (iv)  None of these
                        c.   Kunal is working with strings in Python and wants to repeat the word "Hello" multiple times in his
                            output. Which option should he use to repeat the string the required number of times?
                             (i)   String Concatenation operator              (ii)  String Replication operator
                            (iii)  len() function                            (iv)  range() function

                        d.   Sneha wants to display text on multiple lines using a single string in Python. Which escape sequence
                            should she use to insert a new line in the string?

                             (i)  \t                                          (ii)  \n
                            (iii)  \r                                        (iv)  \b

                        e.   Amit wants to create an empty list at the start of his Python program to store values later. Which
                            of the following can be used to create an empty list in Python?

                             (i)  [ ]                                         (ii)  { }
                            (iii)   ( )                                      (iv)  < >

                     2.  Fill in the blanks using the words from the help box.

                                                 string, append, length, lower, function

                        a.   The _______________ function inserts the object passed to it at the end of the list.
                        b.  A _______________ can be defined as a block of reusable code that performs a specific task.

                        c.   The _______________ function converts all uppercase letters to lowercase.
                        d.   A consecutive sequence of characters that is enclosed or surrounded by single or double quotes is
                            known as a _______________.
                        e.  The _______________ function calculates and returns the length of a string supplied as an argument.

                     3.  Write 'T' for true and 'F' for false.
                        a.  Traversing means visiting each element and processing it as required by the program.

                        b.   A single-line string in Python begins and ends with either three single quotes or three
                            double quotes.

                                                                                       Functions, String and List in Python  103

| 100 101 102 103 104 105 106 107 108 109 110 |