wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PYTHON APTITUDE

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

Find the output of the following program:

a = {i: i * i for i in range(6)} print (a)

a)
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
b)
{0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5}
c)
{0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6}
d)
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 24}
2.

What is the output of the following program : 

print 0.1 + 0.2 == 0.3

a)

0.3

b)
True
c)

False

d)

Error

3.

What is the output of this program?

a)

Runtime Error

b)

16

c)
4
d)

Indentation Error

4.

What is the output of the expression : 3*1**3

a)
27
b)
9
c)
3
d)

1

5.

What is the output of the following program : 

a)

0

1

2

3

0

b)

0

1

2

0

c)

0

1

2

d)

Error

6.
  1. Which line of code produces an error?

(a)  “one” + “2”

(b)  ‘5’ + 6

(c)   3 + 4

(d)  “7” + ‘eight’

a)

(a)

b)

(b)

c)

(c)

d)

(d)

7.
  1. Identify the invalid variable name in python?

(a)  this_is_a_variable = 7

(b)  abc = 10.22

(c)  ThisBook = “python”

(d)  %name = “xyz”

a)

(a)

b)

(b)

c)

(c)

d)

(d)

8.

Find the output of this code:

a)

loop

b)

No Output

c)

Infinite Looping

d)

Error

9.
  1. How many numbers will be printed?

a)

5

b)

6

c)

4

d)

0

10.
  1. Identify whether the given loop is definite or indefinite.

a)

Definite

b)

Indefinite

11.

How many numbers will be printed by this code?

a)

0

b)

1

c)

9

d)

10

12.

If list  = [1,2,3,4,5] then list[5] will result in _______

a)

4

b)

"list Index out of range" Error

c)

1

d)

5