Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Function & Scope of variable in Python

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What will be the output of the following Python code?

a)

212

32

b)

9

27

c)

567

98

d)

None of the mentioned

2.

What will be the output of the following Python code?

a)

Function returns the sum

of all values

6

15

b)

Function returns the sum

of all values

6

100

c)

123

12345

d)

None of the mentioned

3.

What is a variable defined outside a function referred to as?

a)

A static variable

b)

A global variable

c)

A local variable

d)

An automatic variable

4.

What is a variable defined inside a function referred to as?

a)

A global variable

b)

A volatile variable

c)

A local variable

d)

An automatic variable

5.

What will be the output of the following Python code?

a)

1

b)

Nothing is displayed

c)

0

d)

An exception is thrown

6.

What will be the output of the following Python code?

a)

10

56

b)

45

56

c)

10

20

d)

Syntax Error

7.

What will be the output of the following Python code?

a)

An exception is thrown because of conflicting values

b)

1 2

c)

3 3

d)

3 2

8.

What will be the output of the following Python code?

a)

Integer

b)

Tuple

c)

Dictionary

d)

An exception is thrown

9.

What will be the output of the following Python code?

a)

ZZZ

b)

ZZ

c)

An exception is executed

d)

Infinite loop

10.

What will be the output of the following Python code?

a)

4

b)

5

c)

1

d)

An exception is thrown