Docsity

Python for IT Automation - D522 PA multiple choice, Exams of Information Technology

Toggle sidebar
bg1
Western Governors University D 426
Python
for IT Automation
-
D522
PA
multiple
choice
Which function should be used to add
data to a file, such as a network
configuration file?
write()
3 multiple choice options
Based on the Python code snippet:
def greet(name, greeting = "Welcome
to WGU"): return f"{greeting},
{name}!"
What is the purpose of the first line of
code?
To define a function with a default greeting
3 multiple choice options
This Python code snippet returns a syntax
error when run:
def multiply_numbers(num1,
num2) result = num1 *
num2
return result
num1
=
5
num2 = 8
print(multiply_numbers(num1, num2))
Which code adjustment will resolve the
syntax error?
Add a colon after def multiply_numbers(num1, num2).
3 multiple choice options
pf3
pf4
pf5

Partial preview of the text

Download Python for IT Automation - D522 PA multiple choice and more Exams Information Technology in PDF only on Docsity!

Western Governors University D 426

Python for IT Automation - D522 PA

multiple choice

Which function should be used to add data to a file, such as a network configuration file? write() 3 multiple choice options Based on the Python code snippet: def greet(name, greeting = "Welcome to WGU"): return f"{greeting}, {name}!" What is the purpose of the first line of code? To define a function with a default greeting 3 multiple choice options This Python code snippet returns a syntax error when run: def multiply_numbers(num1, num2) result = num1 * num return result num1 = 5 num2 = 8 print(multiply_numbers(num1, num2)) Which code adjustment will resolve the syntax error? Add a colon after def multiply_numbers(num1, num2). 3 multiple choice options

Based on the Python snippet: devices = ["router01", "switch01", "modem01", "gateway01", "printer01"] Which data structure is being used to store the names for various types of devices within devices? List 3 multiple choice options

What will be the result of this Python expression? result = 5 + 3 * 2

3 multiple choice options What is the purpose of the is operator in Python? To check if two variables refer to the same object in memory 3 multiple choice options What is the result of this Python expression? bool(0) False 2 multiple choice options Which method is used to return the number of elements in a list? len() 3 multiple choice options Which of the following is used to declare a function in Python? def 3 multiple choice options

What is the output of the following code? print(3 ** 2)

3 multiple choice options How can you convert the string “ 123 ” into an integer in Python? int("123") 3 multiple choice options What is the default value of the step parameter in Python’s string slicing?

3 multiple choice options Which of the following methods removes whitespaces from the beginning and the end of a string in Python? strip() 3 multiple choice options What will be the result of this Python code? fruits = [ ‘ apple’, ‘ banana’, ‘ cherry’] print(fruits[-1]) cherry 3 multiple choice options Which of the following creates a dictionary in Python? {key: value} 3 multiple choice options Which Python method is used to add an item to the end of a list? append() 3 multiple choice options Which operator is used to check if an element exists in a list? in 3 multiple choice options What is the output of the following code? print( “ Hello ” + “ World ” ) HelloWorld 1 multiple choice option How would you access the value associated with the key “ name ” in the dictionary below? person = { “ name ” : “ John ” , “ age ” : 30} person["name"] 3 multiple choice options Which Python method is used to combine two lists? extend() 3 multiple choice options

How do you declare an empty set in Python? set() 3 multiple choice options What is the output of the following Python code? False x = (^5) 3 multiple choice options y = 10 print(x == y)