Python QB
Python QB
2 1 R
4 1 U
5 1 R
6 1 R
7 1 U
9 2 U
10 2 U
11 2 U
13 2 U
14 2 A
15 1 U
16 3 U
17 3 R
L=[“Amit”,”Sumit”,”Naina”]
L1=[“Sunil”]
print(L + L1)
20 3 R
23 3 R
25 4 R
26 3 U
27 4 R
30 4 A
31 4 U
32 4 U
35 4 U
36 5 U
38 Statement 1: 5 A
The child's __init__() function overrides the inheritance of
the parent's __init__() function.
Statement 2:
super() function will make the child class inherit all the
methods and properties from its parent.
Select the correct option related to statement1 and
statement 2.
39 5 U
40 5 U
class A:
print("Inside class")
A()
A()
obj=A()
43 5 A
46 6 A
47 6 U
48 6 A
50 6 U
51 6 A
print(type(mytuple))
53 3 A
55 1 R
56 1 R
57 1 U
58 1 R
61 1 R
62 1 R
63 1 R
64 1 U
list1=[1,3,4,2]
x=list1.pop(2)
print(set([x]))
set1={"a",3,"b",3}
set1.remove(3)
68 6 A
69 5 A
70 5 A
72 4 U
73 4 A
74 6 A
y = 10
x = y += 2
print(x)
a = [10, 20]
b=a
b += [30, 40]
print(a)
print(b)
a=7
77 2 A
b=4
c=5
print(a & b)
print(a & c)
print(b & c)
count = 0
while(True):
if count % 3 == 0:
print(count, end = " ")
if(count > 15):
break;
count += 1
79 2 A
(i) Changeable
81 3 U
82 4 A
try:
print(x)
except:
print(""An exception occurred"")
84 1 R
85 1 R
86 1 R
88 1. i = 0 2 U
2. while i < 3:
3. print(i)
4. i += 1
5. else:
6. print(0) What will be the output of this
statement?
89 3 A
90 4 R
1. def cube(x):
2. return x * x * x
3. x = cube(3)
4. print x
92 1. mytuple1=(5, 1, 7, 6, 2) 2 U
2. mytuple1.pop(2)
3. print(mytuple1)
94 4 U
95 5 U
96 my_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 5 U
Which element will be printed with the following comma
print my_list[-1]
97 4 U
98 4 A
99 5 R
100 4 U
101 4 R
Select the correct output of the following code
optionb
None of
Brackets Indentation Key
these
optiond
Python runs on
an interpreter
Python can be
system,
treated in a
Python can be meaning that
procedural
used on a code can be
way, an None of
server to executed as
object- these
create web soon as it is
oriented way
applications. written. This
or a functional
means that
way.
prototyping can
be very quick.
optionc
int x
int x=17 x=17 declare x=17
x=17
optiond
Data type of
variable name Variable
variable Variable name
can contain name can
names should can begin with
both letters begin with
not be underscore.
and numbers. number.
declared.
optionb
None of
Tuple List Set
these
optiond
None of the
lower case UPPER CASE Capitalized
mentioned
optionb
optionb
Statement1 Statement1 Statement1 Statement1
true and true and false and false and
Statement2 Statement2 Statement2 Statement2
false true false true
optionb
None of the
for do-while while
mentioned
optionc
While loop is
used when While loop is
multiple used when
for loop can
statements multiple
Loops are used be used to
are to statements are
to perform iterate
executed to executed
certain tasks through the
repeatedly repeatedly until
repeatedly. elements of
until the given the given
lists.
condition condition
becomes becomes False.
True.
optiona
Python has
switch
None of the
0 1 statement but
mentioned
we can not use
it.
optionb
optiona
None of the
flow of control selection Iteration
mentioned
optionb
64 512 16 32
optiond
optionb
optiona
optionb
[‘Amit’ ,
[‘Amit’ , ‘Sumit’
‘Sumit’ , List can not none of the
, ‘Naina’ ,
‘Naina’ , concatenate mentioned
[‘Sunil’]]
‘Sunil’]
optiona
optionb
sampleSet.dis
sampleSet.pop( del sampleSet None of the
card("Orange"
"Orange") ["Orange"] mentioned
)
optionc
Statement A is Statement A is Statement A is Statement A
false and false and true and is true and
Statement B is Statement B is Statement B is Statement B
false true true is false
optionc
a tuple can
a tuple can
a tuple can a tuple can contain
contain both
contain only contain only either string
integers and
integers as its strings as its or integer but
strings as its
elements. elements. not both at a
elements.
time.
optiona
Arbitary
None Null 0
value
optiond
Decomposing
Improving Reducing
complex All of the
clarity of the duplication of
problems into mentioned
code code
simpler pieces
optionc
When
duplicate
More than one keys
Keys must be Keys must be
key isn’t encountered,
immutable integers
allowed the last
assignment
wins
optiond
optionb
__module.py_
package.py __init__.py __package__.py
_
optionc
optiond
Another All of the
Module Class
function mentioned
optionb
Statement 1 is Statement 1 is Statement 1 is Statement 1
true and true and false and is false and
statement 2 is statement 2 is statement 2 is statement 2
false true false is true
optiona
No, it is not
def def sample(-
possible in def sample(null)
sample(*data) 1)
Python
optionb
Built-in
System function & Custom
User function
function User defined function
function
System function & Custom
User function
function User defined function
function
optiona
initilized
constructor destructor method
method
optionb
overloading
derived class base class and object and
and
and base class derived class method
overriding
optionc
optionc
optionc
Private
Protected Inheritance is
The inheriting members of a
members of a one of the
class is called class can be
class can be features of
a subclass inherited and
inherited OOP
accessed
optionc
optiond
optionc
When
invoking the
The value of a constructor
A non-private A derived private variable from a
method in a class is a in the subclass, the
superclass can subset of superclass can constructor
be overridden. superclass. be changed in of superclass
the subclass. is
automatically
invoked.
optiond
Statement A is Statement A is Statement A is Statement A
True and True and False and is False and
Statement B is Statement B Statement B is Statement B
False is True False is True
optionc
optiona
None of the
f.read(5) f.read() f.reads(5)
above
optiona
All of the
open() new() Opens()
mentioned
optionc
All of the
open() close() read()
mentioned
optiona
None of the
try except finally
mentioned
optiond
The finally
To throw (or block, if
The try block
raise) an specified, will
lets you test a All of the
exception, use be executed
block of code mentioned.
the raise regardless if the
for errors.
keyword. try block raises
an error or not.
optionb
<class
< 'tuple'> <class 'string'> string
'tuple'>
thistuple = thistuple =
x = ("apple",
("apple", ("apple",
"banana", optiond
"banana",
y = "banana",
y =
"cherry")
y = list(x) "cherry")
("orange",) "cherry")
list(thistuple)
y.remove("appl
y[1] = "kiwi" thistuple += y
e")
thistuple = All of the
x = tuple(y)
print(thistuple tuple(y) mentioned
)
print(x)
fruits = fruits = fruits1 = fruits =
("apple", ("apple", ("apple", ("apple",
optionb
"banana",
mytuple = "banana",
mytuple = "banana",
mytuple = fruits "banana",
mytuple = 2 -
"cherry")
fruits1 * 2 "cherry")
fruits * 2 "cherry")
*2 "cherry")
fruits **
optionb
print(mytuple
print(mytuple) print(mytuple) print(mytuple)
)
optiona
optiond
All of the
3 + 2j -100j 5j above are
correct
optiond
optionb
None of the
.p .py .python
above
optionb
Python is a
Python is an Python is an
high level All of the
interpreted object-oriented
programming above
language. language.
language.
optionb
// # ! /*
optiond
All of the
else import raise
above
optiona
optiona
All of the
+ Append extend
mentioned
optiond
optionb
It removes It removes only
It removes No such
element with the first
element 3 function
index position occurance of 3
from set1 exists for set
3 from set1 from set1
optionb
optiona
optiond
optionb
global automatic
local variable static Variable
variable variable
optionc
declare
def function def declare
function
function_name( function_name() function_nam
function_nam
): : e():
e():
optiona
Readcharacter
Read() Readall() Readchar()
s()
optiond
10 12 14 Syntax error
4 4 5 4 optiona
5 4 5 5
optiona
4 4 5 5
optionc
Logical error
causing
0 1 2 …. 15 0 3 6 9 12 15 0 3 6 9 12
infinite
looping
optiona
optionc
Statement 1 is Statement 1 is Statement 1 is Statement 1
True and False and True and is False and
Statement 2 is Statement 2 is Statement 2 is Statement 2
True. True. False. is False .
optiona
Neither (i)
(i) (ii) (i), (ii)
nor (ii)
optiona
Neither (i)
(i) (ii) (i), (ii)
nor (ii)
optionc
optionb
optionc
optionc
optionb
list1.addLast(5
list1.addEnd(5) list1.append(5) list1.add(5)
)
optionc
optiona
ValueError TypeError
0 1
occurs occurs
optiona
32 64 33 27
optionc
9 3 27 30
optionc
None of the
51762 No output AttributeError
these
optiond
optionc
optiona
optionb
8 9 0 1
optionb
infile =
infile = infile =
infile = open(file =
open(“c:\ open(“c:\\
open(file = “c:\ “c:\\
scores.txt”, scores.txt”,
scores.txt”, “r”) scores.txt”,
“r”) “r”)
“r”)
optionb
infile.readline
infile.read(2) infile.read() infile.readline()
s()
optiona
None of the
open( ) new( ) Open( )
mentioned
optiona