Python Question and Answers
Python Question and Answers
COMPUTER SCIENCE
QNO1. Which of the following symbols are used for comments in Python?
(A) //
(B) ''
(C) /**/
(D) #
(A) function
(B) def
(C) method
(D) All of these
QNO3 Which of the following is correct way to declare string variable in Python?
(A) def __init__()
(B) def _init_()
(C) _init_()
(D) All of these
QNO6 How to find the last element of list in Python? Assume `bikes` is the name of list.
(A) bikes[0]
(B) bikes[-1]
(C) bikes[lpos]
(D) bikes[:-1]
QNO7 If a='cpp', b='buzz' then which of the following operation would show 'cppbuzz' as
output?
Mock Questions By Ashwin Rai
(A) a+b
(B) a+''+b
(C) a+""+b
(D) All of the above
c = a-b
print(c)
(A) cpp-buzz
(B) cppbuzz
(C) TypeError: unsupported operand
(D) None of the above
QNO9 a = 8.6
b=2
print a//b
(A) 4.3
(B) 4.0
(C) 4
(D) compilation error
QNO 10
a = True
b = False
c = True
if not a or b:
print "a"
print "b"
print "c"
Mock Questions By Ashwin Rai
else:
print "d"
(A) a
(B) b
(C) c
(D) d
1. For the following program answer the questions that follow (select any one of the choices):
def fun1(x,y):
returnx+y
a='2'
b='3'
c=fun1(a,b)
print(c)
(d) What will be the output if a and b have values as a=[1,2] and b=[9,10]
Mock Questions By Ashwin Rai
(i) def fun1(x,y): (ii) return x+y (iii) c=fun1(a,b) (iv) None of these
A B
A local scope i value automatically assigned if parameter is not passed
B positional argument ii accessed within a function
C global scope iii specify parameter and its value in function call
D default argument iv accessed in all the functions
E named argument v function call must match number and order of arguments
Ans:
MCQ QUESTIONS
Answers
a)Foreign Transfer protocol b)Fiber Tech Protocol c)Fiber Transfer Protocol d)None Of These Ans:d
9)The fraudulent practice of sending emails purporting to be from reputable companies in order
to induce individuals to reveal personal information is called_______________
a)IT act 2000 b)IT act 2008 c)IT act 2003 d)None of these Ans:a
4.a 5.b 6.c 7.b 8. C 9.b 10.b 11.b 12.b 13.d 14.d 15.c
CLASS XII
COMPUTER SCIENCE
___________________________________________________________
4. Write the names of the modules which are required to use these built-in functions:-
i)randrange() ii)abs()
Answer:i)random ii)math
6. Which keyword in SQL is used to find unique values from various duplicate values in
a column.
Answer:DISTINCT
Answer:COMMIT
Mock Questions By Ashwin Rai
usernames,passwordsetc
Answer:Phishing
COMPUTER SCIENCE
1 What is the output of this expression, 3*1**3?
a) 27
b) 9
c) 3
d) 1
Answer: c
Explanation: First this expression will solve 1**3 because exponential has higher
precedence than multiplication, so 1**3 = 1 and 3*1 = 3. Final answer is 3.
2 What will be the output of the following Python code?
x =['ab','cd']
foriin x:
i.upper()
print(x)
a)[‘ab’,‘cd’]
b)[‘AB’,‘CD’]
c)[None,None]
d) none of the mentioned
Answer: a
Explanation: The function upper() does not modify a string in place, it returns a new
string which isn’t being stored anywhere.
Mock Questions By Ashwin Rai
b) X**y
c) X^^y
d) None of the mentioned
Answer: b
Explanation: In python, power operator is x**y i.e. 2**3=8.
10 What is the answer to this expression, 22 % 3 is?
a) 7
b) 1
c) 0
d) 5
Answer: b
Explanation: Modulus operator gives the remainder. So, 22%3 gives the remainder, that
is, 1.
SUBJECT COMPUTER SCIENCE