0% found this document useful (0 votes)
1 views4 pages

Grade 12 Cs Using Python Libraries

The document contains a worksheet for students at Velammal Vidhyashram, Surapet, focusing on Python programming using random libraries. It includes multiple-choice questions and coding exercises that require students to predict outcomes of various Python code snippets involving random number generation and list manipulation. Additionally, it covers concepts such as range functions, statistical functions, and basic programming constructs.

Uploaded by

praveenku1122000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

Grade 12 Cs Using Python Libraries

The document contains a worksheet for students at Velammal Vidhyashram, Surapet, focusing on Python programming using random libraries. It includes multiple-choice questions and coding exercises that require students to predict outcomes of various Python code snippets involving random number generation and list manipulation. Additionally, it covers concepts such as range functions, statistical functions, and basic programming constructs.

Uploaded by

praveenku1122000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VELAMMAL VIDHYASHRAM, SURAPET

USING PYTHON LIBRARIES – WORKSHEET

[Link] are the possible outcome(s) from the following code?


import random PICK=[Link] (1,3)
CITY= ["DELHI", "MUMBAI", "CHENNAI", "KOLKATA"]
for I in CITY:
for J in range (0, PICK):
print (I, end = "")
print ()

(Ia) (ib) (ic) (id)


DDELHIDELHI DDELHI DDELHI DDELHI
MMUMBAIMUMBAI DDELHIMUMBAI MMUMBAI MMUMBAIMUMBAI
CCHENNAICHENNAI DDELHIMUMBAICHENNAICCHENNAI KKOLKATAKOLKATAKOLKATA
KKOLKATAKOLKATA KKOLKATA

2. What are the possible outcome(s) from the following code? Also, specify the
maximum and minimum values that can be assigned to variable SEL.
import random
SEL=random. randint (1, 3)
ANIMAL = ["DEER", "Monkey", "COW", "Kangaroo"]
for A in ANIMAL:
for AA in range (0, SEL):
print (A, end ="")
print ()

a) b) c) d)
DEERDEER DEER DEER DEER
MONKEYMONKEy DELHIMONKEY MONKEY MONKEYMONKEY
COWCOW DELHIMONKEYCOW COW KANGAROOKANGAROOKANGAROO
KANGAROOKANGAROO KANGAROO

3. What are the possible outcome(s) executed from the following code ?
import random
def main():
p = "MY PROGRAM"
i=0
while p[i] != "R":
l = [Link](0,3) + 5
print (p[l],end ="_")
i += 1
main()
a)G_O_A_A b)R_O_A_R_ c)G_G_R_O d)O_A_R_R_

4. Which is the incorrect outcome executed from the following code? Also,
specify the maximum and minimum values that can be assigned to variable
x=3
N = [Link] (1, x)
for i in range (N):
print (i, "#", i + 1)

a) 0#1 b)0#1 c) 0#1 d) 0#1


1#2 1#2 1#2
2#3 2#3
3#4
5. Which is the incorrect outcome executed from the following code?
import random
movie_list = ['The Jungle Book', 'Finding Nemo', 'Harry Potter', 'The Incredibles', 'Frozen']
movie1 = [Link](movie_list)
movie2 = [Link](movie_list)
print ( movie1 ," or " ,movie2)
(i) Finding Nemo or Harry Potter
(ii) Harry Potter or Toy Story
(iii) Frozen or The Jungle Book
(iv) Toy Story or Spider Man
6. What are the possible outcome(s) executed from the following code ? Also
specify the maximum and minimum values that can be assigned to variable PICKER.
import random N=3
PICKER = [Link] (1, N)
COLOR = ["BLUE", "PINK", "GREEN", "RED"]
for I in COLOR :
for J in range (0, PICKER):
print (I, end = " ")
print ()

(i) (ii) (iii) (iv)


BBLUE BBLUE PPINK BBLUEBLUE
PPINK BBLUEPINK PPINKGREEN PPINKPINK
GGREEN BBLUEPINKGREEN GGREENRED GGREENGREEN
RRED BBLUEPINKGREENRED GGREENGREEN
7. Which is the correct outcome executed from the following code?
import random
n1= [Link](1, 10, 2)
n2= [Link](1, 10, 3)
print (n1,"and",n2)
1. 2 and 7
2. 3 and 4
3. 8 and 10
4. 8 and 9
8. What possible outputs(s) are expected to be displayed on screen at
the time of execution of 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=[Link](1,3)
TO=[Link](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#

9. What possible output is expected to be displayed on the screen at the time of execution
of the Python program from the following code?
import random
L=[10,30,50,70]
Lower=[Link](2,2)
Upper=[Link](2,3)
for K in range(Lower, Upper+1):
print(L[K], end="@")
a) 50@70@ b) 90@ c) 10@30@50@ d) 10@30@50@70@

10. Identify the correct output(s) of the following code. Also write the minimum
and the maximum possible values of the variable b.
import random
a="Wisdom"
b=[Link](1,6)
for i in range(0,b,2):
print(a[i],end='#')

(A) W# (B) W#i#


(C) W#s# (D) W#i#s#
FILL IN THE BLANKS/ MULTIPLE CHOICE QUESTIONS

1. randint(1,10) will return values in the range of _______ to _____


2. Name the Python Library module which need to be imported to invoke
the following function:
a) floor()
b) randrange()
c) randint()
d) sin()
3. Choose the correct possible answer(s)
a = [Link](1,5)
b = [Link](1,3)
c = [Link](2,6)
print(a,b,c)
a) 2 1 3 (b) 4 4 4 (c) 3 2 1 (d) 5 3 5
[Link] are the correct ways to generate numbers from 0 to 20
a) range(20) (b) range(0,21) (c) range(21) (d) range(0,20)
5. State if the following statement is True or False:
Using the statistics module, the output of the below statements will be 20:
import statistics
[Link]([10, 20, 10, 30, 10, 20, 30])
6. Predict the output:
import statistics
L=[40,20,30,20,30,10]
print([Link](L))
7. ________________function is used to generate the random number with specified interval.
8. _____________________ function is used to generate floating point random number.
9. State True or False.
The median( ) function from the statistics module is used find the middle value from the
dataset.
10. Write the statement print the5 divisible random value from100 to 500.

You might also like