Skip to content
Pass Any WGU OA Exam Now & Pay After You Pass. Contact Us!
  1. Home
  2. WGU Exams
  3. WGU D522
  4. Set 1
WGU D522 · Python for IT Automation

WGU D522 Practice Questions – Set 1

50 multiple-choice questions with answers and detailed explanations. Untimed — choose an answer to check it instantly.

Question 1 of 50

Which Python function is used to add data to a file?

Question 2 of 50

Which of the following creates a default greeting function in Python?

Question 3 of 50

How do you resolve the syntax error in this Python function?

def multiply_numbers(num1, num2)

result = num1 * num2

return result

Question 4 of 50

Which Python data structure is used to store the following?

devices = [“router01”, “switch01”, “modem01”, “gateway01”, “printer01”]

Question 5 of 50

What does this Python code snippet do?

value = input(“Enter a number: “)

result = int(value) + 10

print(result)

Question 6 of 50

How would you fix this error in the given Python code?

def check_processing_speed(current_speed, threshold_speed):

is_fast_processing = current_speed > threshold_speed

if is_fast_processing:

print(f”The processing speed of {current_speed} GHz is fast.”)

else:

print(f”The processing speed of {current_speed} GHz is not fast enough. Consider an upgrade.”)

Question 7 of 50

Which data structure is best suited for storing immutable network interface records?

Question 8 of 50

What is the index of the element 40 in the list?

numbers = [10, 20, 30, 40]

Question 9 of 50

What are the characteristics of tuples in Python?

Question 10 of 50

What is the error in the following Python code?

port = input(“Secure Web access? Y/N: “)

if port == “Y”

print(“Use port 443.”)

else

print(“Use port 80.”)

Question 11 of 50

What will be the result of this Python expression?

result = 5 + 3 * 2

Question 12 of 50

What is the purpose of the is operator in Python?

Question 13 of 50

What is the result of this Python expression?

bool(0)

Question 14 of 50

Which method is used to return the number of elements in a list?

Question 15 of 50

Which of the following is used to declare a function in Python?

Question 16 of 50

What is the output of the following code?

print(3 ** 2)

Question 17 of 50

How can you convert the string “123” into an integer in Python?

Question 18 of 50

What is the default value of the step parameter in Python’s string slicing?

Question 19 of 50

Which of the following methods removes whitespaces from the beginning and the end of a string in Python?

Question 20 of 50

What will be the result of this Python code?

fruits = [‘apple’, ‘banana’, ‘cherry’]

print(fruits[-1])

Question 21 of 50

Which of the following creates a dictionary in Python?

Question 22 of 50

Which Python method is used to add an item to the end of a list?

Question 23 of 50

Which operator is used to check if an element exists in a list?

Question 24 of 50

What is the output of the following code?

print(“Hello” + “World”)

Question 25 of 50

How would you access the value associated with the key “name” in the dictionary below?

person = {“name”: “John”, “age”: 30}

Question 26 of 50

Which Python method is used to combine two lists?

Question 27 of 50

What is the output of this Python code?

numbers = [1, 2, 3]

numbers[0] = 10

print(numbers)

Question 28 of 50

What will this code return?

my_str = “Hello World”

print(my_str[0:5])

Question 29 of 50

What does this Python code output?

print(2 * 3 ** 2)

Question 30 of 50

How can you create a tuple in Python?

Question 31 of 50

Which of the following is not a valid Python data type?

Question 32 of 50

Which keyword is used to define a class in Python?

Question 33 of 50

What does the following Python expression return?

len([10, 20, 30])

Question 34 of 50

Which of the following Python keywords is used to create a loop?

Question 35 of 50

How do you remove an element from a list in Python?

Question 36 of 50

What does the continue statement do in Python loops?

Question 37 of 50

What is the output of this code?

my_str = “Hello”

print(my_str[-1])

Question 38 of 50

What does this Python code return?

x = 7

y = 5

print(x % y)

Question 39 of 50

How do you declare an empty set in Python?

Question 40 of 50

What is the output of the following Python code?

x = 5

y = 10

print(x == y)

Question 41 of 50

Which method is used to get the index of an element in a list?

Question 42 of 50

What is the result of this Python expression?

not True and False

Question 43 of 50

Which keyword is used to handle exceptions in Python?

Question 44 of 50

What is the output of this Python code?

print(len(“Python”))

Question 45 of 50

What does the pop() method do in Python?

Question 46 of 50

Which of the following is a valid function definition in Python?

Question 47 of 50

Which of the following will create an empty list?

Question 48 of 50

How can you concatenate two tuples in Python?

Question 49 of 50

What will be the output of the following Python code?

x = [1, 2, 3]

y = x

y.append(4)

print(x)

Question 50 of 50

What is the result of this Python expression?

5 // 2

Set 1 complete

You scored 0%

0 correct out of 0 answered (50 questions in this set).

Next: Set 2

Struggling with WGU D522?

If this exam is giving you a hard time, let us be your helping hand. Contact us, and we'll provide the assistance you need to pass and move forward.

Chat Now