Font size
WorksheetsABREDES - Devasc Python
Total questions: 14
Worksheet time: 8mins
What command is used to install Python modules from PyPI? (Choose two.)
pip load packagename
pip install packagename
python3 -m pip install packagename
python3 -t pip install packagename
What is the standard for indention in Python?
One space for each block of code
Four spaces for each block of code
One tab for each block of code
One tab and one space per block of code
How are comments in Python denoted?
// on each line you want to make a comment
# or '" quotation marks encompassing multiline comments
/* comment */
@$ comment %@
Which of the following are mutable data types? (Choose two.)
Lists
Dictionary
Integers
Tuples
Which of the following would create a dictionary?
a= (" name","chris","age",45)
a= dict()
a= {" name":"chris", "age": 45}
a= [name, chris, age, 45]
What data type does the input() function create when assigned to a variable?
List
Raw
String
An auto typed one
Which print statement is valid for Python 3?
print 'hello world'
print("hello world')
print(hello, world)
print("'hello world'")
How do if statements operate?
If evaluates a variable against a condition to determine whether the condition is true
If uses Boolean operators
An if statement needs to end with :
All of the above are correct
Which statements are true about the range() function? (Choose two.)
The range() function iterates by one, starting at 0, up to but not including the number specified.
The range() function iterates by one, starting at 1, up to the number specified.
A range() function cannot count down, only up.
A range() function can count up or down, based on a positive or negative step value.
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?
['SW4']
['SW1', 'SW2', 'SW3']
['SW1', 'SW2', 'SW3',´SW4´]
['SW4', 'SW2', 'SW3',´SW1´]
['SW4', 'SW1', 'SW2',´SW3´]
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?
RT1
[´RT2´, 'SW1´, 'SW2']
SW1
SW2
an error message
A developer needs to check the version of the running Python package. Which command should the developer use?
python3 -i
python3 -q
python3 --v
python3 -V
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?
float
string
integer
boolean
Which Python programming function is used to display output?
while
if
for
