Question Bank Subject: Computer Science: Class: XII Sub. Code: 083

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

QUESTION BANK

SUBJECT : COMPUTER SCIENCE


Class: XII Sub. Code: 083

CHAPTERS
Python Revision Tour
Functions

1. Find the output of the following code:

s='sCHool2@com'
k=len(s)
m=""
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalnum():
m=m+s[i]
else:
m=m+'bb'
print(m)

a) SchOOL2bbCOM b) school2bbcom c) SCHOOLbbbbCOM


d)None of these

2. What is NOT true about pass statement in Python?


a) It is a null statement
b) The interpreter ignores a pass statement like in the case of a comment
c) Nothing happens when a pass statement is executed
d) None of these

3. Considet two tuples T1=(1,2,4) and T2=(8,9). What will be the result T2+T1?
a) (1,2,4,8,9) b) (8,9,1,2,4) c) 24 d)Results into an error

4. Given a function that does not return any value, what value is thrown by default
when executed in shell?
a) int b) bool c) void d) None

5. Which of the following will run without errors?


a) round(3.7)   b) round(123.34,2,1) c) round()   d) None of these
6. What error occurs when you execute the following code?
apple=mango

1
a) Syntax Error   b) NameError   c) ValueError   d) TypeError

7. Which of the follwing is NOT a complex number in Python?


a) k=2+4j b) k=complex(2,4)
c) k=2+4i d) k=2+4J

8. What is the ouptut of the following code?


i=1
while True:
if i%0x7==0:
break
print(i,end='')
i+=1
a) 123456 b)1234567 c) Error d)Infinite loop

9. What will be printed by the following?


print("xyyzxyzxzzyy".count('yy',1,5))

a)2 b)0 c)1 d)Error


10. Which of the following command will create a list?
a) list1=list() b)list1=[ ]
c)list1=list([1,2,3]) d)All of the above

11. What is the output of the following code?


a=("hello")*3
print(a)
a)hellohellohello b)(‘hello’,’hello’,’hello’)
c)Error d)None of these

12. Which keyword is used to define a function?


a)define b)DEF c)def d)func

13. Find the output


t1=(1,2,(4,5))
t2=(1,2,(3,4))
t1<t2
a) True b) False c) Error, < cannot be used on tuples
d) Error, < can be used on tuples but not on sub-tuples

14. What will be the output when the following code is executed?
x=100
def func(x):
x=2
func(x)
print(x)
a)2 b)100 c)SyntaxError d)102
15. What will be the output of below Python code?

2
def func(a,b=5,c=10):
print('a is',a,'and b is',b,'and c is',c)
func(3,7)
func(25,c=24)

a) a is 7 and b is 3 and c is 10
a is 25 and b is 5 and c is 24
b) a is 3 and b is 7 and c is 10
a is 5 and b is 25 and c is 24
c) a is 3 and b is 7 and c is 10
a is 25 and b is 5 and c is 24
d)None of these

16. What is the advantage of functions in python?

a) Functions reduce duplication of code


b) They can be used to decompose complex problems into simpler pieces
c) They improve the clarity of the code
d) All the above

17. Which of the following is a function call for the function named ‘func’?
a) call func()
b) def func()
c) func()
d) None of the above
18. Functions that are already defined in python is called________
a) user defined functions
b) library functions
c) built-in functions
d) Both b and c
19. Which of the following statement is not true regarding functions?

a) A function definition begins with “define”


b) A function may or may not have parameters.
c) A function may or may not return value.
d) Function header always ends with a colon (:).
20. Choose the correct statement
a) We can create function with no argument and no return value.
b) We can create function with no argument and with return value(s)
c) We can create function with argument(s) and no return value.
d) All of the above

You might also like