wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Assessment Batch 3 MCQ

Total questions: 60

Worksheet time: 40mins

Name
Class
Date
1.

What type of data is the following?: X = "195.67"

a)

Float

b)

String

c)

Boolean

d)

integer

2.

What is the output when the following Python code is executed?

a = 3

b = '5'

c = '2'

print(a * b + c)

a)

17

b)

352

c)

5552

d)

Error message

3.

What is the output of the following Python code?

a = 13.5

b = -24.6

a, b = b, a

print(a, b)

a)

13.5 -24.6

b)

-24.6 13.5

c)

-13.5 24.6

d)

13.5 24.6

4.

str1='101'

x=int(str1)

z=x+400

print(z)

a)

101400

b)

x400

c)

501

d)

none of above

5.

What will be the output of below Python code?

str1="Information"

print(str1[2:8])

a)

format

b)

formatio

c)

orma

d)

ormat

6.

What will be the output of the code given below?

# Code snippet starts

org = ‘QuizOrbit’

print(org[-1:-6:-1])

# Code snippet ends

a)

tibrO

b)

Orbit

c)

Quiz

d)

QuizOrbit

7.

If S="Be positive", what will be the value of

print(S[:2]+S[2:])

a)

p

b)

Space

c)

Be positive

d)

Error

8.

If S="2021 - a ray of hope"

S.islower() gives

a)

True

b)

False

9.

string = "Slartibartfast"

Which Python string method checks if every character in string is a letter (a-z) or a number (0-9)?

a)

string.isdigit()

b)

string.isnumeric()

c)

string.isalpha()

d)

string.isascii()

10.

Choose the odd one from the following methods , for a list "mylist" in python

a)

mylist.append(x)

b)

mylist.count(x)

c)

mylist.sort()

d)

mylist.format()

11.

Correct code to access the second 'Terry' in this list ... ?

a)

montyPython[5]

b)

montyPython[6]

c)

montyPython[-1]

d)

montyPython[3]

12.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

13.

To insert an the string "Pedro" in the starting position of a the nameList we use

a)

nameList.append("Pedro, 1")

b)

nameList.insert("Pedro",0)

c)

nameList.insert(1, "Pedro")

d)

nameList.insert(0, "Pedro")

14.

Result of the program above is

a)

('1', '2', '3', '4', '5')

b)

(1, 2, 3, 4, 5)

c)

12345

d)

"12345"

15.

Which of the following is true ?

a)

Both a and b are assigned values (1,2,3)

b)

b is assigned a value of [2,3]

c)

b is assigned a value of (2,3)

d)

Both a and b are assigned values [1,2,3]

16.

What is the output of the program above ?

a)

b is bigger

b)

a is bigger

c)

Syntax error : tuples can't be compared

d)

None of these

17.

Which of the following options will not result in an error when performed on tuples in Python where tupl=(5,2,7,0,3)?

a)

tupl[1]=2

b)

tupl.append(2)

c)

tupl1=tupl+tupl

d)

tupl.sort()

18.

What is the output of the program above

a)

7

b)

6

c)

5

d)

9

e)

4

19.

What will be the output of the following Python code?

nums = set([1,1,2,3,3,3,4,4])

print(len(nums))

a)

7

b)

Error, invalid syntax for formation of set

c)

4

d)

8

20.

________________method will returns number of key-value pairs in the given dictionary.

a)

len( )

b)

pop( )

c)

del( )

d)

keys( )

e)

values( )

21.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

22.

What is the output?

a)

250.0

b)

200.0

c)

300.0

d)

350.0

23.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

24.

Given the nested if-else structure below, what will be the value of x after code execution completes.

a)

2

b)

0

c)

3

d)

4

25.

What is the value of x after the following nested for loop completes its execution?

a)

99

b)

90

c)

100

d)

0

26.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

27.

The equivalent of the above for loop using the while syntax would be

a)
b)
c)
d)
28.

How many times will 1 be printed

a)

3

b)

4

c)

5

d)

6

29.

What does this program print

a)

2 + 2 = 4

4 + 4 = 8

8 + 8 = 16

16 + 16 = 32

32 + 32 = 64

b)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

c)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

2 + 10 = 12

d)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

e)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

30.
a)
10  8  6  4  2
b)
10
8
6
4
2
c)
2  4  6  8  10
d)
10  9  8  7  6  5  4  3  2  1
31.

Which of these in not a built in function?

a)

int()

b)

power()

c)

len()

d)

type()

32.

A variable that’s declared inside a function is ____ to that function

a)

private

b)

specific

c)

global

d)

local

33.

times is ________________ type of argument.

a)

default arguments

b)

keyword arguments

c)

positional arguments

d)

arbitrary positional arguments

e)

arbitrary keyword arguments

34.
How do you correctly call this function
a)
def(1)
b)
x=square( )
c)
defSquare(4)
d)
x=square(5)
35.

What is the returned value of recmethod(5)?

a)

68

b)

70

c)

75

d)

82

36.

What is printed as a result of the call stri("COMPSCI")?

a)

COMPSCI

COMPSC

COMPS

COMP

COM

CO

C

b)

COMPSCI

OMPSCI

MPSCI

PSCI

SCI

CI

I

c)

CO

COM

COMP

COMPS

COMPSC

COMPSCI

d)

C

CO

COM

COMP

COMPS

COMPSC

COMPSCI

37.

exp(),floor()belongs which module?

a)

cmath.py

b)

urlib.py

c)

math.py

d)

statistics.py

38.

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)

a)

Rectangle

b)

Trapezium

c)

Triangle

d)

Square

39.
To stop the turtle drawing you need to use which of the following commands?
a)
penup:
b)
pen_up( )
c)
penup( )
d)
penup( ):
40.
When you want to hide the turtle pointer on the screen which command should you use?
a)
hide_turtle( )
b)
remove_turtle( )
c)
hideturtle( )
d)
turtle.disappear( )
41.

What are the attributes to the BankAccount class?

a)

Deposit & withdrawal

b)

owner & balance

c)

BankAccount

d)

string & Dollars

42.

In the statement

Bank tom = Bank(5000.0);

Which is the object?

a)

Bank

b)

tom

c)

new

d)

5000.0

43.

What is wrapping of data into a single unit called class called?

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

44.

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?

a)

Inheritance

b)

Polymorphism

c)

Abstraction

d)

Encapsulation

45.

What type of inheritance is illustrated in the following Python code?

class A():

pass

class B(A):

pass

class C(B):

pass

a)

Multi-level inheritance

b)

Multiple inheritance

c)

Hierarchical inheritance

d)

Single-level inheritance

46.

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()

a)

test of B called

test of C called

b)

test of C called

test of B called

c)

test of B called

d)

Error, both the classes from which D derives has same method test()

47.

Which of the following variable is declared as static?

a)

Home address of a particular Student

b)

Account number of a Customer

c)

Company name of all Employees in an Organization

d)

Name of a Employee

48.

Encapsulation and abstraction differ as ____________?

a)

Binding and Hiding respectively

b)

Hiding and Binding respectively

c)

Can be used any way

d)

Hiding and hiding respectively

49.

In Python, private members are identified by

a)

_ prefix

b)

_ suffix

c)

__ prefix

d)

__ suffix

50.

The suspicious code is put inside the

a)

Try Block

b)

Finally Block

c)

Else Block

d)

Except Block

51.

How does run() method is invoked?

a)

By Thread.run()

b)

By Thread.start()

c)

By Thread.create()

d)

None

52.

Which thread method is used to wait until it terminates?

a)

waitforthread()

b)

join()

c)

None

d)

wait()

53.

_______________ and __________________ are the types of synchronization.

a)

Process synchronization and thread synchronization

b)

multitasking and multithreading

c)

Interthread communication and mutual exclusion

d)

None

54.

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","__")

a)

r

b)

a

c)

w

d)

x

55.

Which statement(s) is/are true to open a binary file "Record.dat" for reading and writing.

a)

file =open("Record.dat","wb")

b)

file =open("Record.dat","rb")

c)

file =open("Record.dat","ab")

d)

file =open("Record.dat","rb+")

56.

The meaning of the meta character * is

a)

One or more occurrences

b)

Occurrences only for Numbers

c)

Zero or more occurrences

d)

Occurrences only for strings

57.

[^pqr] returns a

a)

Match for characters p, q, r, P, Q and R only

b)

Match for characters p, q, and r only

c)

Match for any character contain p, q, and r

d)

Match for any character except p, q, and r

58.

The _________ statement is used to delete a table.

a)

DROP TABLE

b)

DELETE TABLE

c)

DEL TABLE

d)

REMOVE TABLE

59.

In the following line of code, which is is an OBJECT?

canvas1.create_line(0, 0, 200, 100)

a)

create_line

b)

canvas1

c)

0

d)

200

60.

To display all the databases of MySQL with the help of cursor mycursor , command will be

a)

mycursor.execute("SHOW DATABASES")

b)

mycursor.execute("DESC DATABASES")

c)

mycursor.executes("SHOW DATABASES")

d)

mycursor.execute("SHOW ALL DATABASES")