wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Basic Python

Total questions: 10

Worksheet time: 12mins

Name
Class
Date
1.

What is output of 33 == 33.0

a)

False

b)

True

c)

33

d)

None of the Above

2.

How can we swap two numbers

a = 10

b = 20

in python without using third variable?

a)

a = b

b = a

b)

a,b = b,a

c)

a=20,b=10

d)

b = a

a = b

3.

Which of the following are valid ways to specify the string literal foo'bar in Python?

a)

'foo''bar'

b)

'foo'bar'

c)

"foo'bar"

d)

'foo'+'bar'

4.

>>> print(r'foo\\bar\nbaz')

Which of the following is the correct output?

a)

foo\\bar\nbaz

b)

foo\bar\nbaz

c)

foo\\barnbaz

d)

foo\bar

baz

5.

Which of the following is not a Python built-in function:

a)

diff()

b)

round()

c)

isinstance()

d)

map()

6.

Which of the following is false statement in python

a)

int(144)==144

b)

int('144')==144

c)

int(144.0)==144

d)

None of the above

7.

What is the output for −

'Hello world' [1:2]

a)

Hello

b)

e

c)

world

d)

Syntax error

8.

What is the output of this code snippet?

a)

10

b)

Runtime Error

c)

Syntax error

d)

0

9.

Suppose you are given with two sets(s1&s2) then what is the output of the code s1+s2

a)

Adds the elements of the both the sets.

b)

Removes the repeating elements and adds both the sets.

c)

It is an illegal command.

d)

Output will be stored in S1.

10.

 What is the output of this code snippet?


a)

2,2,2

b)

1,2,5

c)

1,2,3

d)

ERROR