Worksheet on Functions and modules in Python

Q.1: Which of the function return the smallest integer not less than number .

a) exp()

b) ceil()

c) floor()

d) fabs()

 

Q.2:Which of the following is not a type of function ?

a) built in function

b) function defined in modules

c) user defined function

d) python function

 

Q.3 : …………… is a reserved word  for defining a function .

a) fun

b) def

c) define

d) pyfun

 

Q.4:What is the output of math.ceil(89.7)?

a) 90

b) 7

c) 89

d) 80

 

Q.5:What is the another name of parameters ?

a) formal argument

b) actual argument

c) actual parameters

d) none of these

 

Q.6: Out of the following ,which function should we use to generate random numbers between 1 and 5 ?

a) random()

b) randint()

c) range()

d) generate()

 

Q.7:What is the default value of a function that does not return any value ?

a) None

b) int

c) double

d) null

 

Q.8: A _______ is a file( .py file ) that contains variables , class , statements related to particular task.

a) function

b) module

c) docstring

d) none of these

 

Q.9:Which of the following is the form of  import statement ?

a) import<module name>

b) from <module> import <object>.

c) import py.<module name>

d) all of these

 

Q.10:The  help statement display __________ from a module .

a) constants

b) fuctions

c) classes

d) docstrings

 

Q.11: A ______ is a named block of statements that can be invoked by its name .

 

Q.12: The  ______ function returns the largest integer  not greater than number.

 

Q.13:The  ______ module of python provides random number generation functionality .

 

Q.14:How are the following two statements differ from one another ?

a) Import maths

b) From maths import*

 

Q.15 :What is the utility of random module ?

 

Q.16 :What is the significance of modules?

 

Q.17: What is the role of an argument of a function?

 

 

Solution for Worksheet on Functions and modules in Python

 

 

Q.1: Which of the function return the smallest integer not less than number .

b) ceil()

 

Q.2:Which of the following is not a type of function ?

d) python function

 

Q.3 : …………… is a reserved word  for defining a function .

b) def

 

Q.4:What is the output of math.ceil(89.7)?

a) 90

 

Q.5:What is the another name of parameters ?

a) formal argument

 

Q.6: Out of the following ,which function should we use to generate random numbers between 1 and 5 ?

b) randint()

 

Q.7:What is the default value of a function that does not return any value ?

a) None

 

Q.8: A __________ is a file( .py file ) that contains variables , class , statements related to particular task.

b) module

 

Q.9:Which of the following is the form of  import statement ?

c) import py.<module name>

 

Q.10:The  help statement display ______ from a module .

d) docstrings

 

Q.11: A _____ is a named block of statements that can be invoked by its name .

Answer : function

 

Q.12: The  ______ function returns the largest integer  not greater than number.

Answer : floor()

 

Q.13:The  ______ module of python provides random number generation functionality .

Answer : random

 

Q.14:How are the following two statements differ from one another ?

a) Import maths and b) From maths import*

Answer:

When you type ‘import math’ you are importing all functions and classes in the math module but when you type ‘from math import [name of class]’, you only get access to that class in the whole module. you may write this ‘from math import *’ to import everything from the “from” statement

 

Q.15 :What is the utility of random module ?

Answer:

Python Random module is an in-built module of Python which is used to generate random numbers. These are pseudo-random numbers means these are not truly random. This module can be used to perform random actions such as generating random numbers, print random a value for a list or string, etc

 

Q.16 :What is the significance of modules?

Answer:

A module allows you to logically organize your Python code. Grouping related code into a module makes the code easier to understand and use. A module is a Python object with arbitrarily named attributes that you can bind and reference. Simply, a module is a file consisting of Python code.

 

Q.17: What is the role of an argument of a function?

Answer:

Arguments are inputs to functions; they allow a function to produce different (but appropriate) outputs for different inputs.The terms parameter and argument can be used for the same thing: information that are passed into a function. From a function’s perspective: A parameter is the variable listed inside the parentheses in the function definition. An argument is the value that are sent to the function when it is called.

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved
error: Content is protected !!