You are on page 1of 5

DELHI PUBLIC SCHOOL KALYANPUR

CLASS-XII
SUBJECT-COMPUTER SCIENCE
REVISION WORKSHEET-1

1. Fill in the blanks.


(a) is the Python operator responsible for declaring variables.
(b) The variable declared outside all the functions is called a ____ variable.
(c) In Python, the non-zero value is treated as and zero value is treated as____
2. State whether the following statements are True or False.
(i) Function can alter only mutable data types.
(ii) More than one value(s) can be returned by a function in Python.
(iii) Relational operators return either true or false.
3. Multiple Choice Questions.
(i) What will be the output of the following code:
print(“100+200”)?
(i)300 (ii)100200 (iii)100+200 (iv)200
(ii) Fill in the line of code for calculating the factorial of a number:
def fact(num):
if num==0:
return 1
else:
return__ __
(i) num*fact(num-1) (ii)(num-1)*(num-2) (iii)num*(num-1) (iv)fact(num)*fact(num-1)

4. Answer the following questions:


1. Amit was working on application where he wanted to divide the two number (A and B) , he has
written the expression as C = A/B, on execution he entered 30 and 7 and expected answer was 4
i.e. only integer part not in decimal, but the answer was 4.285 approx, help Amit to correct his
expression and achieving the desired output.
Correct Expression :
2. Can you guess the output?
C = -11%4
print(C)
3. Write statement to call the function.
def Add():
X = 10 + 20
print(X))
#statement to call the above function
4. Write Output of :
True + True =
100 + False =
-1 + True =
bool(-1 + True) =
5. Write Output of :
a,b,c = 20,40,60
b+=10
c+=b
print(a,b,c)
6. Solve it:
“Computer Science”[0:6] =
“Computer Science”[3:10] =
“Computer Science”[::-1] =
“Computer Science”[-8:] =

7. Which line number code will never execute?


def Check(num): #Line 1
if num%2==0: #Line 2
print("Hello") #Line 3
return True #Line 4
print("Bye") #Line 5
else: #Line 6
return False #Line 7
C = Check(20)
print(C)
8. Ravi a python programmer is working on a project, for some requirement, he has to define a
function with name CalculateInterest(), he defined it as:
def CalculateInterest(Principal,Rate=.06,Time): # code
But this code is not working, Can you help Ravi to identify the error in the above function and what is the
solution
9. What will be the output of the following code?
Def drawline(char=‟$‟,time=5):
print(char*time)
drawline()
drawline(„@‟,10)
drawline(65)
drawline(chr(65))
10. Write a program to enter 2 numbers and find sum and product.

11. Consider a list:


MyFamily = [“Father”,”Mother”,”Brother”,”Sister”,”Jacky”]
write statement to print “Brother”
write statement to print all items of list in reverse order
write statement to check “Sister” is in MyFamily or not
write statement to update “Jacky” with “Tiger”
write statement remove “Jacky” from MyFamily and also print it
write statement to add “Tommy” in MyFamily at the end
12. Predict the output of the following code:
a=10
y=5
def myfunc(a):
y=a
a=2
print(“y=”,y, ”a=”,a)
return a+y
print(“y=”,y, ”a=”,a)
print(myfunc(a))
print(“y=”,y,”a=”,a)
13. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
Else:
print (K+3)
14. Write a program to enter any number and check it is divisible by 7or not.
15. Convert the following “for‟ loop using “while‟ loop:
for k in range (10,20,5):
print(k)
16. Find and write the output of the following python code:
Msg="CompuTer"
Msg1=' '
for i in range(0, len(Msg)):
if Msg[i].isupper():
Msg1=Msg1+Msg[i].lower()
elif i%2==0:
Msg1=Msg1+'*'
else:
Msg1=Msg1+Msg[i].upper()
print(Msg1)
DELHI PUBLIC SCHOOL KALYANPUR
CLASS-XII
SUBJECT-COMPUTER SCIENCE
REVISION WORKSHEET-2

I. Fill in the blanks.


(a) The built-in function randrange()belongs to_ module.
(b) A__ _ is just a module that contains some useful definitions.
(c) The first line of a function definition is called___ .
II. State whether the following statements are True or False.
(1) A function in Python is used by invoking it via a function call.
(2) A stream is defined as a sequence of characters.
III. Multiple Choice Questions.
(1) Suppose list1=[0.5*x for x in range(0,4)],list1 is:
(i)[0,1,2,3] (ii)[0,1,2,3,4] (iii)[0.1,0.5,1.0,1.5]

(iv)[0.0,0.5,1.0,1.5,2.0]
(2) pow()function belongs to which library?
(i) math (ii)strings (iii)random (iv)maths
(3) Which arithmetic operators cannot be used with strings?
(i) + (ii)* (iii)- (iv)All of these

IV. Suppose a tupple T is declared as:


T=(10,12,43,39) which of the following is correct?
A)Print(T[1]) B)T[2]=-29 (c)Print(max(t)) d)print(len(t)).
V. What will be the output of following code?
def Fun1(mylist):
for i in range(len(mylist)): if
mylist[i]%2==0:
mylist[i]/=2
else:
mylist[i]*=2
list1 =[21,20,6,7,9,18,100,50,13]
Fun1(list1)
print(list1)

VI. What will be the output of following code?


def Fun1(num1):
num1*=2
num1=Fun2(num1) return num1
def Fun2(num1):
num1 = num1 // 2
return num1
n = 120
n=Fun1(n)
print(n)
VII. What will be the output of following code?
def drawline(char='$',time=5):
print(char*time)
drawline()
drawline('@',10)
drawline(65)
drawline(chr(65))
VIII. What will be the output of following code?
a=100
def show():
global a a=200
def invoke():
global a
a=500
show()
invoke()
print(a)
IX. What will be the output of following code?
def Calculate(A,B,C):
return A*2, B*2, C*2
val = Calculate(10,12,14)
print(type(val))
print(val)

You might also like