CS 12 Python Libraries
CS 12 Python Libraries
1 Python Student will be able At least 15-20 minutes talk Students should be Worksheet 1
Libraries to understand the on the topic advised to see Notes: Teacher will provide
Module, Concept of: INTRODUCTION: these Videos. a common email address to (One word answer
Library, *A library is a collection of various https://youtu.be/ all students for the quiz to Based worksheet with
Name *Library packages. knEGv2yfHLs receive score or can design answers)
Space, *Module *A module is simply a python file & their own quiz’s in google
Package as *Name Space where statements, classes, https://youtu.be/ form Worksheet 2
covered in *Package Objects, functions, constants and QYcVky9kvw0
Class XII *Random module variables are defined. https://docs.google.com/ CBSE Based
*importing library *A python name space is a forms/d/e/ Problem
collection of names. It is 1FAIpQLSdGpBgkfE34F- (This section contains
essentially a mapping of names to 1YDsRMmiuoj8864rZ8Jgn7Z 6 solved question
corresponding objects. TT5l4RcLmh1JA/viewform? based on CBSE exam
*Python package is a collection of usp=sf_link with answers)
related modules.
*Random module of Paython Worksheet 3
provides random number Link for Practical
generation functionality. (Unsolved CBSE MCQ
Explanation of these topic Teacher can put link of Questions)
Link of PPT practical demonstration
http://python.mykvs.in/ Modules with function
presentation/presentation2021/ can be memorized by
class%20xii/computer
%20science/Using%20python Memorizing modules
%20libraries.pdf
Worksheet 1
(Concept of Python Libraries)
Name of the Vidyalaya: ___________________________________________
Name of Student: ____________Class & Section: ________Roll No____
3 We can use any Python source file as a module by executing an ________ statement.
_______________ function, when applied to a module, gives you the names of all that is defined inside
4
the module.
5 The ____________ is a variable that holds the name of the module being referenced.
6 A ___________ is a variable that holds the name of the module being referenced.
(a) Libraries
(b) Package
(c) Import
(d) dir()
(e) _name_
(f) Module
(g) Random-number generation
(h) Name spaces
(i) Global, local, built-in
Worksheet 2
Study the following program and select the possible output(s) from the options (i) to (iv)
1 following it. Also, write the maximum and the minimum values that can be assigned to the
variable Y.
import random
X=random.random()
Y=random.randint(0,4)
print int(X),”:”,Y+int(X)
i) 0 : 0 ii) 1 : 6 iii) 2 : 4 iv) 0 : 3
2 Observe the following program and answer the questions that follow:
import random
X=3
N=random.randint(1,X)
for i range(N):
print i,”#”,i+1
a) What is the minimum and maximum number of times the loop will execute?
b) Find out, which line of output(s) out of (i) to (iv) will not be expected from the
program?
(i) 0#1 (ii) 1#2 (iii) 2#3 (iv) 3#4
What possible outputs(s) are expected to be displayed on screen at the time of execution of
3 the program from the following code? Also specify the maximum values that can be assigned
to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”# “)
(i) 10#40#70# (ii) 30#40#50# (iii)50#60#70# (iv) 40#50#70#
What possible outputs(s) are expected to be displayed on screen at the time of execution of
4 the program from the following code? Also specify the maximum values that can be assigned
to each of the variables START and END. 2
import random
SCORE=[20,40,10,30,15];
START=random.randint(1,3)
END=random.randint(2,4)
for I in range(START,END+1):
print SCORE[I],"&",
(i) 10&40&20& (ii) 10&30&15& (iii) 40&10&30& (iv) 20&40&10&
5
What are the possible outcome(s) executed from the following code? Also specify the
maximum and minimum values that can be assigned to variable N.
import random
PLAY=[40,50,10,20]"EAST","WEST","NORTH","SOUTH";
ROUND=random.randint(2,3)
for J in range(ROUND,1,–1):
print PLAY[J],”:”
(i) 20:10: (ii) 20:10:50: (iii) 20: (iv) 40:50:20:
What possible output(s) are expected to be displayed on screen at the time of execution of the
6 program from the following code ? Also specify the maximum values that can be assigned to
each of the variables BEGIN and LAST. 2
import random
POINTS=[20,40,10,30,15];
POINTS=[30,50,20,40,45];
BEGIN=random.randint(1,3)
LAST=random.randint(2,4)
for C in range(BEGIN,LAST+1):
print POINTS[C],"#"
(i) 20#50#30#(ii) 20#40#45#(iii) 50#20#40#(iv) 30#50#20#
math module
log()/pow()/gamma()/sin()/cos()/tan()/factorial()/degrees()/radians()/remainder()/comb()/dist()/exp()/erf()/
ceil( )/floor()/trunk()/fabs()/abs()
statistics module
mean()/median()/mode()
random module
randint()/randrange()/getrandbits()/setstate()/getstate()/uniform()/speed()/choice()/choices()/shuffle()
/sample()/random()/triangular()/gauss()