wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Topic Quiz-1 : Python Basics

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.

Which code prints the output [3,7,8] for a given list -

[ [1,2,3] , [5,6,7] , [0,9,8] ]

a)

[i[2] for i in list]

b)

[i(2) for i in list]

c)

[i[3] for i in list]

d)

(i(3) for i in list)

2.

tuple=(10,20,30,40,50)

Which code prints the output(50,40,30,20,10) :

a)

tuple(-1::)

b)

tuple(::-1)

c)

tuple(Sort)

d)

set(tuple)

3.

Given a function that does not return any value, What value is thrown by default when executed in shell.

a)

int

b)

Null

c)

void

d)

None

4.

What will be the output of the following Python code?

str1 = 'hello'

str1=str1+2

a)

hello2

b)

Error

c)

hello

d)

hello 2

5.

Guess the output :

a)

[[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]

b)

[[0], [[0], 1], [[0], [[0], 1], 2]]

c)

[0, None, 1, None, 2, None]

d)

[[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]

6.

Which of the following are true of Python lists?

a)

There is no conceptual limit to the size of a list

b)

These represent the same list:

['a', 'b', 'c']

['c', 'a', 'b']

c)

A given object may appear in a list more than once

d)

A list may contain any type of object except another list

7.

What is the result of this statement:

{'b', 'a', 'r'} & set('qux')

a)

{'b', 'r', 'a'}

b)

set()

c)

{'q', 'r', 'x', 'u', 'b', 'a'}

d)

{}

8.

Consider the above code snippet -

# Python 3. dict.keys() returns a view object, not a list

a)

apple

orange

banana

b)

None

c)

RuntimeError: dictionary changed size during iteration

d)

There will be no output.

9.

Mutable datatypes in python -

a)

List

b)

Strings

c)

Dictionary

10.

Which of these is called lazy evaluation.

a)

range()

b)

xrange()