Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 165 - CodePilot V5.0 C8
P. 165

    D.  Answer the following questions:
                        1.  What is a string in Python?

                        2.  Name any four built-in list functions in Python.

                        3.  Explain the concept of List in Python programming.

                        4.  Differentiate between built-in and user-defined functions.

                        5.  What do you understand by library in Python?

                                                                                                    21 st
                     COMPETENCY-BASED QUESTIONS                                                   Century   #Critical Thinking
                                                                                                   Skills  #Technology Literacy
                     1.   Karthik wants to capitalise the first letter of a sentence entered by the user before storing it in a
                        variable. Which Python function can he use?
                     2.   Simran has strings for her address (street, city, state) and wants to join them into one

                        address string with spaces in between. Which string operator can she use?

                                  LAB LEARNING                                              21 st
                                                                                           Century   #Critical Thinking
                                                                                            Skills  #Technology Literacy
                            1.  Find the output of the following Python code:

                                (a) def square(x):                    (b) def divide(a, b):
                                        return x * x                           return a / b
                                    result = square(4)                     answer = divide(10, 2)
                                    print(result)                          print(answer)

                                Output:                               Output:
                                (c) numbers = [10, 20, 30]            (d) word = "Python"

                                    numbers.remove(20)                     print(word[0:3])
                                    print(numbers)                         print(word[::-1])
                                Output:                               Output:

                            2.   From the list given below, use functions to display only the numbers that are divisible by 5.
                                Stop the loop if a number greater than 80 is encountered.

                                numbers = [10, 12, 15, 20, 33, 45, 50, 60, 85, 90]
                            3.  Write a Python program that takes a word from the user and reverse it.

                                                                                                                      163
                                                                                                Step Ahead with Python

| 160 161 162 163 164 165 166 167 168 169 170 |