Font size
WorksheetsPython Assessment Batch 3 MCQ
Total questions: 60
Worksheet time: 40mins
What type of data is the following?: X = "195.67"
Float
String
Boolean
integer
What is the output when the following Python code is executed?
a = 3
b = '5'
c = '2'
print(a * b + c)
17
352
5552
Error message
What is the output of the following Python code?
a = 13.5
b = -24.6
a, b = b, a
print(a, b)
13.5 -24.6
-24.6 13.5
-13.5 24.6
13.5 24.6
str1='101'
x=int(str1)
z=x+400
print(z)
101400
x400
501
none of above
What will be the output of below Python code?
str1="Information"
print(str1[2:8])
format
formatio
orma
ormat
What will be the output of the code given below?
# Code snippet starts
org = ‘QuizOrbit’
print(org[-1:-6:-1])
# Code snippet ends
tibrO
Orbit
Quiz
QuizOrbit
If S="Be positive", what will be the value of
print(S[:2]+S[2:])
p
Space
Be positive
Error
If S="2021 - a ray of hope"
S.islower() gives
True
False
string = "Slartibartfast"
Which Python string method checks if every character in string is a letter (a-z) or a number (0-9)?
string.isdigit()
string.isnumeric()
string.isalpha()
string.isascii()
Choose the odd one from the following methods , for a list "mylist" in python
mylist.append(x)
mylist.count(x)
mylist.sort()
mylist.format()
Correct code to access the second 'Terry' in this list ... ?
montyPython[5]
montyPython[6]
montyPython[-1]
montyPython[3]
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
nameList[1]
NameList(4)
nameList["4"]
To insert an the string "Pedro" in the starting position of a the nameList we use
nameList.append("Pedro, 1")
nameList.insert("Pedro",0)
nameList.insert(1, "Pedro")
nameList.insert(0, "Pedro")
Result of the program above is
('1', '2', '3', '4', '5')
(1, 2, 3, 4, 5)
12345
"12345"
Which of the following is true ?
Both a and b are assigned values (1,2,3)
b is assigned a value of [2,3]
b is assigned a value of (2,3)
Both a and b are assigned values [1,2,3]
What is the output of the program above ?
b is bigger
a is bigger
Syntax error : tuples can't be compared
None of these
Which of the following options will not result in an error when performed on tuples in Python where tupl=(5,2,7,0,3)?
tupl[1]=2
tupl.append(2)
tupl1=tupl+tupl
tupl.sort()
What is the output of the program above
7
6
5
9
4
What will be the output of the following Python code?
nums = set([1,1,2,3,3,3,4,4])
print(len(nums))
7
Error, invalid syntax for formation of set
4
8
________________method will returns number of key-value pairs in the given dictionary.
len( )
pop( )
del( )
keys( )
values( )
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
250.0
200.0
300.0
350.0
What is the output?
3
3
7
3
5
7
7
Given the nested if-else structure below, what will be the value of x after code execution completes.
2
0
3
4
What is the value of x after the following nested for loop completes its execution?
99
90
100
0
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
The equivalent of the above for loop using the while syntax would be
How many times will 1 be printed
3
4
5
6
What does this program print
2 + 2 = 4
4 + 4 = 8
8 + 8 = 16
16 + 16 = 32
32 + 32 = 64
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 4 = 6
2 + 6 = 8
2 + 8 = 10
2 + 10 = 12
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 4 = 6
2 + 6 = 8
2 + 8 = 10
8
6
4
2
Which of these in not a built in function?
int()
power()
len()
type()
A variable that’s declared inside a function is ____ to that function
private
specific
global
local
times is ________________ type of argument.
default arguments
keyword arguments
positional arguments
arbitrary positional arguments
arbitrary keyword arguments
What is the returned value of recmethod(5)?
68
70
75
82
What is printed as a result of the call stri("COMPSCI")?
COMPSCI
COMPSC
COMPS
COMP
COM
CO
C
COMPSCI
OMPSCI
MPSCI
PSCI
SCI
CI
I
CO
COM
COMP
COMPS
COMPSC
COMPSCI
C
CO
COM
COMP
COMPS
COMPSC
COMPSCI
exp(),floor()belongs which module?
cmath.py
urlib.py
math.py
statistics.py
What will be the output shape of the following Python code?
import turtle
t=turtle.Pen()
for i in range(1,4):
t.forward(60)
t.left(90)
Rectangle
Trapezium
Triangle
Square
What are the attributes to the BankAccount class?
Deposit & withdrawal
owner & balance
BankAccount
string & Dollars
In the statement
Bank tom = Bank(5000.0);
Which is the object?
Bank
tom
new
5000.0
What is wrapping of data into a single unit called class called?
Abstraction
Polymorphism
Encapsulation
Inheritance
What is the process of using a function for more than one purpose that allows the use of different internal structures of the object by keeping the same external interface?
Inheritance
Polymorphism
Abstraction
Encapsulation
What type of inheritance is illustrated in the following Python code?
class A():
pass
class B(A):
pass
class C(B):
pass
Multi-level inheritance
Multiple inheritance
Hierarchical inheritance
Single-level inheritance
What will be the output of the following Python code?
class A:
def test1(self):
print(" test of A called ")
class B(A):
def test(self):
print(" test of B called ")
class C(A):
def test(self):
print(" test of C called ")
class D(B,C):
def test2(self):
print(" test of D called ")
obj=D()
obj.test()
test of B called
test of C called
test of C called
test of B called
test of B called
Error, both the classes from which D derives has same method test()
Which of the following variable is declared as static?
Home address of a particular Student
Account number of a Customer
Company name of all Employees in an Organization
Name of a Employee
Encapsulation and abstraction differ as ____________?
Binding and Hiding respectively
Hiding and Binding respectively
Can be used any way
Hiding and hiding respectively
In Python, private members are identified by
_ prefix
_ suffix
__ prefix
__ suffix
The suspicious code is put inside the
Try Block
Finally Block
Else Block
Except Block
How does run() method is invoked?
By Thread.run()
By Thread.start()
By Thread.create()
None
Which thread method is used to wait until it terminates?
waitforthread()
join()
None
wait()
_______________ and __________________ are the types of synchronization.
Process synchronization and thread synchronization
multitasking and multithreading
Interthread communication and mutual exclusion
None
Mode in the following program to open file for writing in a mode where new data will be added at the end of old data
file =open("poem.txt","__")
r
a
w
x
Which statement(s) is/are true to open a binary file "Record.dat" for reading and writing.
file =open("Record.dat","wb")
file =open("Record.dat","rb")
file =open("Record.dat","ab")
file =open("Record.dat","rb+")
The meaning of the meta character * is
One or more occurrences
Occurrences only for Numbers
Zero or more occurrences
Occurrences only for strings
[^pqr] returns a
Match for characters p, q, r, P, Q and R only
Match for characters p, q, and r only
Match for any character contain p, q, and r
Match for any character except p, q, and r
The _________ statement is used to delete a table.
DROP TABLE
DELETE TABLE
DEL TABLE
REMOVE TABLE
In the following line of code, which is is an OBJECT?
canvas1.create_line(0, 0, 200, 100)
create_line
canvas1
0
200
To display all the databases of MySQL with the help of cursor mycursor , command will be
mycursor.execute("SHOW DATABASES")
mycursor.execute("DESC DATABASES")
mycursor.executes("SHOW DATABASES")
mycursor.execute("SHOW ALL DATABASES")
