wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 30

Worksheet time: 16mins

Name
Class
Date
1.

Python is a

a)

Object Oriented Programming

b)

Interpreted Programming

c)

High Level Programming

d)

All the Above

2.

Which can be an Identifier among them in Python?

a)

$123

b)

_abc

c)

@fg

d)

1a

3.

What is the data type of print(type(10))

a)

<class 'int'>

b)

int

c)

integer

d)

<class 'integer'>

4.
Predict the Output
x = 'abcd'
for i in x:
    print(i.upper())
a)

Syntax Error

b)

a B C D

c)

a b c d

d)

A B C D

5.

All keywords in Python are in _________?

a)

Capitalized

b)

Lower case

c)

Upper Case

d)

None of the mentioned

6.

What will be the output of the following Python code?

for i in range(1,5):

if i==4:

continue

print(i)

a)

1 2 3 4 5

b)

1 2 3 5

c)

1 2 3

d)

Error

7.

What is the order of precedence in python?

a)

Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

b)

Exponential, Parentheses, Division, Multiplication, Addition, Subtraction

c)

Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

d)

Parentheses, Exponential, Multiplication, Division, Subtraction, Addition

8.

What is the output of the below code

print("a"+"bc")

a)

bc

b)

abc

c)

aBc

d)

acb

9.

What will be the output of the following Python code?

print("abc. DEF".capitalize())

a)

Abc. def

b)

abc. def

c)

Abc. Def

d)

ABC. DEF

10.

What will be the output of the following Python code?

>>>list1 = [1, 3]

>>>list2 = list1

>>>list1[0] = 4

>>>print(list2)

a)

[1, 4]

b)

[1, 3, 4]

c)

[4, 3]

d)

[1, 3]

11.

What will be the output of the following Python code?

x = 'abcd'

for i in range(len(x)):

print(i)

a)

error

b)

1 2 3 4

c)

a b c d

d)

0 1 2 3

12.

Which of the following is a Python tuple?

a)

{1, 2, 3}

b)

{}

c)

(1, 2, 3)

d)

[1, 2, 3]

13.

Which one of the following is the use of function in python?

a)

Functions are reusable pieces of programs

b)

Functions don’t provide better modularity for your application

c)

All of the mentioned

d)

you can’t also create your own functions

14.

What is output of print(math.pow(3, 2))?

a)

6.0

b)

9.0

c)

9

d)

6

15.

What are the two main types of functions in Python?

a)

System function

b)

Custom function

c)

Built-in function & User defined function

d)

User function

16.

Which of the following code will creates a list?

a)

a = list([1, 2, 3])

b)

a = []

c)

a = list()

d)

all of the mentioned

17.

Suppose list1 is [2, 33, 222, 05, 50], What is list1[-1]

a)

Error

b)

05

c)

50

d)

2

18.

Which arithmetic operators cannot be used with strings

a)

+

b)

-

c)

*

d)

/

19.

Which of the following represents the bitwise XOR operator?

a)

!

b)

^

c)

|

d)

~

20.

What will be the output of the following Python code?

a=[14,52,7]

b=a.copy()

print(b is a)

a)

True

b)

False

c)

0

d)

1

21.

What will be the output of the following Python code?

word1="Apple"

word2="Apple"

list1=[1,2,3]

list2=[1,2,3]

print(word1 is word2)

print(list1 is list2)

a)

True

True

b)

False

True

c)

False

False

d)

True

False

22.
  1. Predict the output
    str1="helloworld"

    str1[::-1]

a)

dlrowolleh

b)

hello

c)

world

d)

helloworld

23.

Predict the output

  1. d = {"john":40, "peter":45}

  2. print(list(d.keys()))

a)

[“john”:40, “peter”:45]

b)

[“john”, “peter”]

c)

(“john”, “peter”)

d)

(“john”:40, “peter”:45)

24.

Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard?

a)

Raw_input & Input

b)

Input & Scan

c)

Scan & Scanner

d)

Scanner

25.

To open a file c:\scores.txt for writing, we use ____________

a)

outfile = open(“c:\scores.txt”, “w”)

b)

outfile = open(“c:\\scores.txt”, “w”)

c)

outfile = open(file = “c:\scores.txt”, “w”)

d)

outfile = open(file = “c:\\scores.txt”, “w”)

26.

To read the next line of the file from a file object infile, we use ____________

a)

infile.read(2)

b)

infile.read()

c)

infile.readline()

d)

infile.readlines()

27.

What is the data type of

a=(1)

a)

Tuple

b)

Integer

c)

List

d)

Both tuple and integer

28.

Which of these about a dictionary is false?

a)

The values of a dictionary can be accessed using keys

b)

Dictionaries aren’t ordered

c)

Dictionaries are mutable

d)

 The keys of a dictionary can be accessed using values

29.

What is the output of the following if statement

a, b = 12, 5

if a + b:

print('TRUE')

else:

print('False')

a)

True

b)

False

c)

Error

d)

TRUE

30.

What is the output of the following Code

aList = [4, 8, 12, 16]

aList[1:4] = [20, 24, 28]

print(aList)

a)

[4, 20, 24, 28, 8, 12, 16]

b)

[4, 20, 24, 28]

c)

[20,24,28,12,16]

d)

[4,20,24,28,16]