Chapter-1&2 Python Revision Tour I&II PDF
Chapter-1&2 Python Revision Tour I&II PDF
Chapter No.: 1, 2
Chapter Name: Python Revision Tour - I & II
1
COMPUTER SCIENCE QUESTION BANK CLASS - XII
2
COMPUTER SCIENCE QUESTION BANK CLASS - XII
3
COMPUTER SCIENCE QUESTION BANK CLASS - XII
4
COMPUTER SCIENCE QUESTION BANK CLASS - XII
5
COMPUTER SCIENCE QUESTION BANK CLASS - XII
6
COMPUTER SCIENCE QUESTION BANK CLASS - XII
7
COMPUTER SCIENCE QUESTION BANK CLASS - XII
8
COMPUTER SCIENCE QUESTION BANK CLASS - XII
9
COMPUTER SCIENCE QUESTION BANK CLASS - XII
10
COMPUTER SCIENCE QUESTION BANK CLASS - XII
11
COMPUTER SCIENCE QUESTION BANK CLASS - XII
12
COMPUTER SCIENCE QUESTION BANK CLASS - XII
98. >>>t=(1,2,3,4)
Write the statement should be used to print the first three elements 3
times
i. >>>print(t*3) ii. >>>t*3
iii. >>>t[:3]*3 iv. >>>t+t
99. Match the output with the statement given in column A with
column B.
1. >>>tuple([10,20,30]) a. >>> (10,20,30)
2. >>>(“Tea”,)* 3 b. >>> 2
3. >>>tuple(“Item”) c. >>> ('Tea', 'Tea', 'Tea')
4. >>>print(len(tuple([1,2]))) d. >>> ('I', 't', 'e', 'm')
i. 1-b,2-c,3-d,4-a ii. 1-a,2-c,3-d,4-b
iii. 1-c,2-d,3-a,4-a iv. 1-d,2-a,3-b,4-c
100. Write the output of the following code:
>>>d={‘name’:’rohan’,’dob’:’2002-03-11’,’Marks’:’98’}
>>>d1={‘name’:‘raj’)
>>>d1=d.copy()
>>>print(“d1 :”d1)
i. d1 : {'name': 'rohan', 'dob': '2002-03-11', 'Marks': '98'}
ii. d1 = {'name': 'rohan', 'dob': '2002-03-11', 'Marks': '98'}
iii. {'name': 'rohan', 'dob': '2002-03-11', 'Marks': '98'}
iv. (d1 : {'name': 'rohan', 'dob': '2002-03-11', 'Marks': '98'})
13
COMPUTER SCIENCE QUESTION BANK CLASS - XII
14
COMPUTER SCIENCE QUESTION BANK CLASS - XII
15
COMPUTER SCIENCE QUESTION BANK CLASS - XII
16
COMPUTER SCIENCE QUESTION BANK CLASS - XII
10. Rewrite the following code in python after removing all syntax
error(s). Underline each correction done in the code.
Num=int(rawinput("Number:"))
sum=0
for i in range(10,Num,3)
Sum+=1
if i%2=0:
print(i*2)
Else:
print(i*3 print Sum)
11. Rewrite the following code in python after removing all syntax
error(s). Underline each correction done in the code.
weather='raining'
if weather='sunny':
print("wear sunblock")
elif weather='snow':
print("going skiing")
else:
print(weather)
12. Write the modules that will be required to be imported to
execute the following code in Python.
def main( ):
for i in range (len(string)) ):
if string [i] = = ‘’ “
print
else:
c=string[i].upper()
print( “string is:”,c)
print (“String length=”,len(math.floor()))
17
COMPUTER SCIENCE QUESTION BANK CLASS - XII
13. Observe the following Python code very carefully and rewrite it
after removing all syntactical errors with each correction underlined.
DEF execmain():
x = input("Enter a number:")
if (abs(x)=x):
print ("You entered a positive number")
else:
x=*-1
print "Number made positive:"x execmain()
14. Rewrite the following code in python after removing all syntax
error(s).Underline each correction done in the code
x=integer(input('Enter 1 or 10'))
if x==1:
for x in range(1,11)
Print(x)
Else:
for x in range(10,0,-1):
print(x)
15. 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)
16. What will be the error of the following code Snippet?
Lst =[1,2,3,4,5,6,7,8,9]
Lst[::2]=10,20,30,40,50,60
Print[Lst]
18
COMPUTER SCIENCE QUESTION BANK CLASS - XII
17. Find the error in following code. State the reason of the error
aLst={‘a’:1,’b’:2,’c’:3}
print(aLst[‘a’,’b’])
18. What will be the output of the following Code Snippet?
a =[1,2,3,4,5]
print(a[3:0:-1])
19. What do you mean by scope of variables?
20. Differentiate between the round( ) and floor( ) functions with the
help of suitable example.
19
COMPUTER SCIENCE QUESTION BANK CLASS - XII
20
COMPUTER SCIENCE QUESTION BANK CLASS - XII
21
COMPUTER SCIENCE QUESTION BANK CLASS - XII
10. Find and write the output of the following python code:
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print (Msg3)
11. Find and write the output of the following python code :
def Changer(P,Q=10):
P=P/Q
Q=P%Q
print (P,"#",Q)
return P
A=200
B=20
A=Changer(A,B)
print (A,"$",B)
B=Changer(B)
print (A,"$",B)
A=Changer(A)
print (A,"$",B)
22
COMPUTER SCIENCE QUESTION BANK CLASS - XII
12. Find and write the output of the following python code:
Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add = 0
for C in range(1,6,2):
Times= Times + C
Alpha= Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times,Add,Alpha)
13. Find and write the output of the following python code:
Text1="AISSCE 2018"
Text2=""
I=0
while I<len(Text1):
if Text1[I]>="0" and Text1[I]<="9":
Val = int(Text1[I])
Val = Val + 1
Text2=Text2 + str(Val)
elif Text1[I]>="A" and Text1[I] <="Z":
Text2=Text2 + (Text1[I+1])
else:
Text2=Text2 + "*"
I=I+1
print (Text2)
23
COMPUTER SCIENCE QUESTION BANK CLASS - XII
14. Find and write the output of the following python code:
TXT = ["20","50","30","40"]
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float (T) + C
print(TOTAL)
CNT-=1
15. Find output generated by the following code:
line = "I'll come by then."
eline = ""
for i in line:
eline += chr(ord(i)+3)
print(eline)
16. Find output generated by the following code:
line = "What will have so will"
L = line.split('a')
for i in L:
print(i, end=' ')
17. Find output generated by the following code:
p=5/2
q=p*4
r=p+q
p+=p+q+r
q-=p+q*r
print(p,q,r)
24
COMPUTER SCIENCE QUESTION BANK CLASS - XII
25
COMPUTER SCIENCE QUESTION BANK CLASS - XII
21. Find and write the output of the following python code:
def fun(s):
k=len(s)
m=" "
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
else:
m=m+'bb'
print(m)
fun('school2@com')
22. Find the output of the give program :
def Change(P ,Q=30):
P=P+Q
Q=P-Q
print( P,"#",Q)
return (P)
R=150
S=100
R=Change(R,S)
print(R,"#",S)
S=Change(S)
23. Find the output of the give program :
x = "abcdef"
i = "a"
while i in x:
print(i, end = " ")
26
COMPUTER SCIENCE QUESTION BANK CLASS - XII
27
COMPUTER SCIENCE QUESTION BANK CLASS - XII
28
COMPUTER SCIENCE QUESTION BANK CLASS - XII
29
COMPUTER SCIENCE QUESTION BANK CLASS - XII
30
COMPUTER SCIENCE QUESTION BANK CLASS - XII
31
COMPUTER SCIENCE QUESTION BANK CLASS - XII
4. t1=(10,20,30,40,50,60,70,80)
t2=t1*2
t3=t2+4
print t2,t3
5. t1=(10,20,30,40,50,60,70,80)
str=””
str=index(t1(40))
print(“index of tuple is ”, str)
str=t1.max()
print(“max item is “, str)
32