using python libraries important questions class 12

important question
of using python libraries

using python libraries

Q 1. name the python library module which need to be imported to invoke the following functions.
(1) sin()
(2) randint()
(3) log()
(4) barh()
(5) float()

(1) math module
(2) random module
(3) math module
(4) matplotlib.pyplot module
(5) built-in function (no module need to be imported)

Q 2. what is the procedure to create own library package in python.

ans. steps
(1) create a package folder having the name of the package/library.
(2) add module files(.py files containing actual code functions) to   package folder.
(3) add a special file to it (even if the file is empty)
(4)attach this package folder to site-packages folder of
       python installation.

Q 3. what is the problem in following piece of code.

 from math import factorial
print(math.factorial(5) ) the “from-import” form of import, the imported identifiers(in this case factorial() ) become part of the current focal namespace and hence their module’s names aren’t specified along with the module name. The statement should be:-

Q 4. what do you understand by standard library of python.

ans. python standard library is the library, which is distributed with python that contains modules for various types of functionalities. Some commonly used modules of python standard library are:-
math module, math module, random module, statistics module, urllib module etc.

Q 5. what is the possible outcomes executed from the following code? Also specify the maximum and minimum values that can be assigned to variable number.

while string[n] != ‘L’ :
print(string[n]+string[number]+’#’,end=’ ‘)

(1)ES#NE#IO#        (2)LE#NO#ON#      (3)NS#IE#LO#       (4)EC#NB#IS#

sol. part (4) can be one of possible outcomes.
        maximum value 3,minimum value 0.

Q 6. consider the following code.

import random
1. print(int(20+random.random()*5),end= ‘  ‘  )
2. print(int(20+random.random()*5),end= ‘  ‘  )
3. print(int(20+random.random()*5),end= ‘  ‘  )
4. print(int(20+random.random()*5))

find the suggested output option (1) to (4).also, write the least value and highest value that can be generated.
(1) 20 22 24 25                                          (2) 22 23 24 25
(3) 23 24 23 24                                           (4) 21 21 21 21

ans. parts (3),(4) can be one of the possible outcomes.
       for expression int(20+random.random()*5):
           maximum value 24,minimum value 20
       for the expression random.random()*5
           maximum value 4.xxxxxx (<5.0),minimum value 0.0.

Q 7. what you understand by package.

ans. python package refer to a directory of python module(s). this feature comes in handy for organizing modules of one type at one place.

Q 8. what do you understand by library.

ans. library is a collection of modules(and packages) that together cater to specific type of applications or requirements.

Q 9. which python library need to be imported to use following function.

                 (1) range()       (2)  arrange()

ans. (1)built-in function  (no module need to be imported)
        (2)numpy module

Q 10. what do you understand by module.

ans. a module is a file containing python definitions, functions, variables, classes and statement.
the extension of this file is “.py”.

You may also like...

1 Response

  1. November 9, 2020

    […] of file handeling (3)using python libraries       notes of using python libraries       important question of using python libraries (4)recursion     notes of recursion    important question of recursion (5)idea of algorithmic […]

Leave a Reply

Your email address will not be published. Required fields are marked *