wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Essentials 1 - Exam

Total questions: 40

Worksheet time: 18mins

Name
Class
Date
1.

How many element does the lst list contain?

a)

zero

b)

three

c)

one

d)

two

2.

What is the output of the following piece of code if the user enters two lines containing 3 and 2 respectively?

a)

3

b)

0

c)

2

d)

1

3.

Which of the following snippet shows the correct way of handling multiple exceptions in a single except clause?

a)
b)
c)
d)
4.

Which of the following lines correctly invoke the function defined below?

(Select TWO answers)

a)

fun (b=1)

b)

fun (b=0, a=1)

c)

fun (0,1,2)

d)

fun(0)

5.

Assuming that my_tuple is a correctly created tuple, the fact that tuples are immutable means that the following instructions:

a)

may be illegal if the tuple contains strings

b)

can be executed if and only if the tuple contains at least two elements

c)

is illegal

d)

is fully correct

6.

Which of the following variable names are ILLEGAL and will cause the SyntaxError exception?

(Select TWO answer)

a)

In

b)

for

c)

print

d)

in

7.

What is the output of the following snippet?

a)

(4,)

b)

44

c)

(4)

d)

4

8.

Which of the following is the correct extension of the Python file?

a)

a) .python

b)

b) .pl

c)

c) .py

d)

d) .p

9.

Which of the following character is used to give single-line comments in Python?

a)

a) //

b)

b) #

c)

c) !

d)

d) /*

10.

What is the greater than symbol:

(a)  

11.

What is the output of the following snippet if the user enters two lines containing 3 and 6 respectively?

a)

333333

b)

18

c)

666

d)

36

12.

What is the output of the following snippet?

a)

x*y*z

b)

x y z

c)

1*1*1

d)

1 1 1

13.

What is the output of the following snippet?

a)

[1, 2, 2, 2]

b)

[1, 1, 1, 2]

c)

[1, 2, 1, 2]

d)

[2, 1, 1, 2]

14.

What is the output of the following code if the user enters 0?

a)

Very very bad input...

b)

0.0

c)

Very bad input...

d)

Booo!

e)

Bad input...

15.

What is the result of the following division?

a)

cannot be predicted

b)

is equal to 0.5

c)

is equal to 0.0

d)

is equal to 0

16.

The meaning of a positional argument is determined by ____

a)

the argument's name specified along with its value

b)

its value

c)

its connection with existing variables

d)

its position within the arguments list

17.

Which of the following sentences are true about the code?

(Select ALL that apply)

a)

vals and nums are different names of the same list

b)

vals is longer than nums

c)

nums and vals are different lists

d)

nums has the same length as vals

18.

An operator able to check whether two values are not equal is coded as ____

a)

!=

b)

not ==

c)

<>

d)

=/=

19.

What is the output of the following snippet?

a)

0 0

b)

1 1

c)

1 0

d)

0 1

20.

What is the output of the following piece of code if the user enters 2 and 4 respectively?

a)

2.0

b)

4.0

c)

0.0

d)

1.0

21.
Which of the following symbols is used in Python to mean "Less than or equal to"?
a)
<<
b)
=<
c)
<=
d)
!=
22.

What brackets are used to create a list?

a)

()

b)

[]

c)

{}

d)

<>

23.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

24.

What is the output of the following piece of code?

a)

2 1 2

b)

1 2 1

c)

1 1 2

d)

1 2 2

25.

The ** operator ______

a)

performs duplicated multiplication

b)

performs floating point multiplication

c)

performs exponentiation

d)

does not exist

26.

What is the output of the following snippet if the user enters two lines containing 3 and 6 respectively?

a)

333333

b)

18

c)

666

d)

36

27.

What is the output of the following snippet?

a)

25.

b)

17.0

c)

17

d)

the code will cause a runtime error

28.

How many hashes (#) will the following snippet sent to the console?

a)

three

b)

nine

c)

zero

d)

six

29.

What is the output of the following snippet?

a)

4

b)

the snippet is erroneous and will cause SyntaxError

c)

2

d)

6

30.

The following snippet ____

a)

will output None

b)

is erroneous

c)

will output 4

d)

will output 2

31.

Take a look at the snippet and choose the true statement or statements

a)

the snippet will cause a runtime error

b)

vals is longer than nums

c)

nums is longer than vals

d)

nums and vals have the same length

e)

both are empty lists

32.

What is the output of the following snippet?

a)

one

b)

two

c)

three

d)

('one', 'two', 'three')

33.

What is the output of the following snippet?

a)

1

b)

2

c)

0

d)

the snippet will cause a runtime error

34.

What is the output of the following snippet?

a)

12

b)

(2,1)

c)

(1,2)

d)

21

35.

What is the output of the following snippet?

a)

[0, 1, 9, 16]

b)

[1, 4, 9, 16]

c)

[0, 1, 4, 9]

d)

[0, 1, 4, 16]

36.
To repeat a fixed number of times use a
a)
while loop
b)
for loop
c)
if loop
d)
indentation
37.

What will happen when you attempt to run the following code?

a)

The code will print Hello, World! to the console

b)

The code will raise the SyntaxError exception

c)

The code will raise the TypeError exception

d)

The code will raise the ValueError exception

38.

What is the output of this code?

a)

112

b)

122

c)

201

d)

121

39.

What is the output of the following piece of code if the user enters 3 and 6 respectively?

a)

6

b)

36

c)

63

d)

3

40.

What is the output of the following snippet?

a)

1

b)

2

c)

0

d)

the snippet will cause a runtime error