Page 115 - Computer - 8
P. 115
4. How many values can be returned by a return statement?
(a) One (b) Two (c) None (d) Infinite
5. The statement that sends back a value from a function is ______.
(a) print (b) def (c) return (d) provide
B. Fill in the blanks with the correct answer.
1. A named block of instructions that can be executed using its name is called _________.
2. The functions provided by Python are called _________.
3. _________ keyword is used to define a function.
4. The values given to a function as input are called _________.
5. The function that lets us add a list to another list is _________.
C. Write ‘T’ for True and ‘F’ for False statement.
1. More than one values can be returned by a function. _______
2. A function, once defined, can be called only once in a program. _______
3. The len( ) function returns the length of a string. _______
4. range( ) is an example of a user-defined function. _______
5. A function may or may not return a value. _______
D. Answer the following questions.
1. What is a function? How is it useful in programming?
2. What is the difference between user-defined and built-in functions?
3. Describe the components of a user-defined function in Python.
4. What is a list? Describe the ways in which a list can be created in Python.
5. Explain any three functions used to work with strings in Python.
Computational Skills
Mind Stretching
1. Write the code segment to perform the following tasks in Python.
(a) Display the last character in a string variable named “Name”.
(b) Add an element “Program” to a list named “Objects”.
(c) Define a function named “Volume” that takes three arguments – l, b, and h, and returns the
volume of the cuboid.
(d) Display all odd numbers from 5 to 30.
2. Identify and underline the errors in the code given below. Also, write the correct code.
(a) # Program to create a function and call it.
print(“Calling the function”)
myFunc1( )
def myfunc1( )
print(“Inside the function”)
return
113