wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

ABREDES - Devasc Python

Total questions: 14

Worksheet time: 8mins

Name
Class
Date
1.

What command is used to install Python modules from PyPI? (Choose two.)

a)

pip load packagename

b)

pip install packagename

c)

python3 -m pip install packagename

d)

python3 -t pip install packagename

2.

What is the standard for indention in Python?

a)

One space for each block of code

b)

Four spaces for each block of code

c)

One tab for each block of code

d)

One tab and one space per block of code

3.

How are comments in Python denoted?

a)

// on each line you want to make a comment

b)

# or '" quotation marks encompassing multiline comments

c)

/* comment */

d)

@$ comment %@

4.

Which of the following are mutable data types? (Choose two.)

a)

Lists

b)

Dictionary

c)

Integers

d)

Tuples

5.

Which of the following would create a dictionary?

a)

a= (" name","chris","age",45)

b)

a= dict()

c)

a= {" name":"chris", "age": 45}

d)

a= [name, chris, age, 45]

6.

What data type does the input() function create when assigned to a variable?

a)

List

b)

Raw

c)

String

d)

An auto typed one

7.

Which print statement is valid for Python 3?

a)

print 'hello world'

b)

print("hello world')

c)

print(hello, world)

d)

print("'hello world'")

8.

How do if statements operate?

a)

If evaluates a variable against a condition to determine whether the condition is true

b)

If uses Boolean operators

c)

An if statement needs to end with :

d)

All of the above are correct

9.

Which statements are true about the range() function? (Choose two.)

a)

The range() function iterates by one, starting at 0, up to but not including the number specified.

b)

The range() function iterates by one, starting at 1, up to the number specified.

c)

A range() function cannot count down, only up.

d)

A range() function can count up or down, based on a positive or negative step value.

10.

A student is learning Python using the interactive interpreter mode. The student issues the commands.


>>> devices=devices + ["RT4", "SW4"]

>>> for i in devices:

... if "R" in i:

... routers.append(i)

... else:

... switches.append(i)

...

>>> switches


What is the result?

a)

['SW4']

b)

['SW1', 'SW2', 'SW3']

c)

['SW1', 'SW2', 'SW3',´SW4´]

d)

['SW4', 'SW2', 'SW3',´SW1´]

e)

['SW4', 'SW1', 'SW2',´SW3´]

11.

A student is learning Python in the interactive interpreter mode. The student issues the commands:


>>> devicenames=["RT1", "RT2", "SW1", "SW2"]

>>> devicenames[-1]


What is the result?

a)

RT1

b)

[´RT2´, 'SW1´, 'SW2']

c)

SW1

d)

SW2

e)

an error message

12.

A developer needs to check the version of the running Python package. Which command should the developer use?

a)

python3 -i

b)

python3 -q

c)

python3 --v

d)

python3 -V

13.

A student is learning Python in the interactive interpreter mode. The student issues the command:


>>> type(True)


What is the data type reported by Python?

a)

float

b)

string

c)

integer

d)

boolean

14.

Which Python programming function is used to display output?

a)

print

b)

while

c)

if

d)

for