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 4
WGU D522 · Python for IT Automation

WGU D522 Practice Questions – Set 4

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

Question 1 of 50

What will be the result of the following code?

x = [1, 2, 3, 4, 5]

y = x[1:4]

print(y)

Question 2 of 50

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

Question 3 of 50

How do you reverse a list x in Python?

x = [1, 2, 3, 4, 5]

Question 4 of 50

What will this Python code output?

print(“Python” + ” is fun”)

Question 5 of 50

Which Python data type is used to store ordered, mutable collections of items?

Question 6 of 50

How would you remove duplicates from a list x in Python?

x = [1, 2, 3, 1, 2, 4]

Question 7 of 50

What is the result of this code?

a = [1, 2, 3]

Question 8 of 50

What is the difference between remove() and pop() in Python?

Question 9 of 50

What is the output of this code?

x = [10, 20, 30, 40, 50]

print(x.pop(2))

Question 10 of 50

What is the output of the following Python code?

x = “Hello World”

print(x.lower())

Question 11 of 50

How do you check the length of a list x in Python?

Question 12 of 50

What will be the output of this code?

x = [1, 2, 3, 4, 5]

print(sum(x))

Question 13 of 50

How do you sort a list x in ascending order?

Question 14 of 50

What is the result of this code?

x = [10, 20, 30, 40]

y = x.copy()

print(x == y and x is y)

Question 15 of 50

Which of the following methods can add an element to the end of a list in Python?

Question 16 of 50

What will this Python code output?

x = [1, 2, 3]

x.insert(1, 5)

print(x)

Question 17 of 50

What will this Python code output?

x = [1, 2, 3]

print(x.index(2))

Question 18 of 50

How do you find the maximum value in a list x in Python?

Question 19 of 50

What is the output of this code?

x = [1, 2, 3, 4, 5]

x.remove(3)

print(x)

Question 20 of 50

Which of the following statements is true about Python dictionaries?

Question 21 of 50

How do you access the value associated with the key “name” in a Python dictionary x ?

x = {“name”: “Alice”, “age”: 25}

Question 22 of 50

What will be the result of this code?

x = {“a”: 1, “b”: 2, “c”: 3}

x[“d”] = 4

print(x)

Question 23 of 50

What is the output of this code?

x = {“a”: 1, “b”: 2, “c”: 3}

print(x.get(“d”))

Question 24 of 50

Which method can be used to remove a key-value pair from a Python dictionary?

Question 25 of 50

What will this Python code output?

x = {1, 2, 3}

x.add(4)

print(x)

Question 26 of 50

How do you find the length of a dictionary x in Python?

Question 27 of 50

What is the output of the following code?

x = {“a”: 1, “b”: 2, “c”: 3}

print(“b” in x)

Question 28 of 50

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

Question 29 of 50

What will this Python code output?

x = [1, 2, 3, 4]

print(x[3:])

Question 30 of 50

What is the correct syntax for defining a class in Python?

Question 31 of 50

What is the output of this Python code?

x = 10

def func():

global x

x = 5

func()

print(x)

Question 32 of 50

How do you create a new instance of a class MyClass in Python?

Question 33 of 50

Which method is called automatically when a new object is created in Python?

Question 34 of 50

What is the output of this Python code?

class MyClass:

def __init__(self):

self.value = 10

obj = MyClass()

print(obj.value)

Question 35 of 50

What will this Python code output?

class MyClass:

def __init__(self):

self.value = 5

def update(self, new_value):

self.value = new_value

obj = MyClass()

obj.update(10)

print(obj.value)

Question 36 of 50

How do you define a method inside a Python class?

Question 37 of 50

What is the purpose of the self parameter in Python class methods?

Question 38 of 50

What is the result of this code?

class MyClass:

def __init__(self):

self.value = 10

obj = MyClass()

del obj

print(obj)

Question 39 of 50

Which of the following can be used to check if an object obj is an instance of class MyClass ?

Question 40 of 50

What is the purpose of inheritance in Python?

Question 41 of 50

How do you inherit a class in Python?

Question 42 of 50

What will this Python code output?

class Parent:

def __init__(self):

self.value = 5

class Child(Parent):

def __init__(self):

Parent.__init__(self)

self.value += 5

obj = Child()

print(obj.value)

Question 43 of 50

How can you override a method in a subclass in Python?

Question 44 of 50

What will this Python code output?

class MyClass:

def __init__(self):

self.value = 5

def method(self):

print(self.value)

obj = MyClass()

obj.value = 10

obj.method()

Question 45 of 50

What is the result of this code?

class MyClass:

def __init__(self):

self.value = 5

obj = MyClass()

obj.new_value = 10

print(obj.new_value)

Question 46 of 50

What is the correct syntax to call a parent class method in a subclass?

Question 47 of 50

How do you define a private attribute in Python?

Question 48 of 50

What is the result of this Python code?

class MyClass:

def __init__(self):

self.__value = 5

obj = MyClass()

print(obj.__value)

Question 49 of 50

What is method overloading in Python?

Question 50 of 50

What is the difference between is and == in Python?

Set 4 complete

You scored 0%

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

Next: Set 5

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