WGU D522 Python Programming Exam This exam preparation document is designed for students t, Exams of Computer Science

WGU D522 Python Programming Exam This exam preparation document is designed for students taking the WGU D522 Python Programming Objective Assessment. It includes 300 exam-style questions with verified answers, fully aligned with the latest updated exam version. The content covers core Python concepts such as variables and data types, control flow, functions, data structures, file handling, error handling, object-oriented programming basics, and practical coding logic. Ideal for structured review or final exam preparation, this resource closely reflects the format and difficulty of the actual exam.

Typology: Exams

2025/2026

Available from 02/03/2026

Ray-shay
Ray-shay 🇺🇸

4K documents

1 / 65

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1 of 51
WGU D522 Python Programming Exam –
Latest Update – Complete 300 Questions with
Verified Answers
Official Exam Overview:
The WGU D522 Python Programming exam evaluates learners’ understanding of Python
programming concepts, including data types, control structures, functions, object-oriented
programming, file handling, and debugging. The exam emphasizes practical coding skills and
problem-solving using Python.
Exam Coverage Areas:
1. Python Data Types and Variables
2. Operators and Expressions
3. Control Structures (loops, conditionals)
4. Functions and Modules
5. Object-Oriented Programming Concepts
6. File Handling and Exceptions
7. Data Structures (lists, dictionaries, tuples, sets)
8. Libraries and Modules
QUESTION 1:
What built-in data type is used when you assign text to your variable?
A) int
B) float
C) str
D) list
Rationale:
In Python, the str data type is used to store text. For example: x = "Hello, World!" assigns a
string to the variable x.
QUESTION 2:
Which of the following correctly creates a list in Python?
A) x = {1, 2, 3}
B) x = [1, 2, 3]
C) x = (1, 2, 3)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41

Partial preview of the text

Download WGU D522 Python Programming Exam This exam preparation document is designed for students t and more Exams Computer Science in PDF only on Docsity!

Page 1 of 51

WGU D522 Python Programming Exam –

Latest Update – Complete 300 Questions with

Verified Answers

Official Exam Overview: The WGU D522 Python Programming exam evaluates learners’ understanding of Python programming concepts, including data types, control structures, functions, object-oriented programming, file handling, and debugging. The exam emphasizes practical coding skills and problem-solving using Python. Exam Coverage Areas:

  1. Python Data Types and Variables
  2. Operators and Expressions
  3. Control Structures (loops, conditionals)
  4. Functions and Modules
  5. Object-Oriented Programming Concepts
  6. File Handling and Exceptions
  7. Data Structures (lists, dictionaries, tuples, sets)
  8. Libraries and Modules QUESTION 1: What built-in data type is used when you assign text to your variable? A) int B) float C) str ✅ D) list Rationale: In Python, the str data type is used to store text. For example: x = "Hello, World!" assigns a string to the variable x. QUESTION 2: Which of the following correctly creates a list in Python? A) x = {1, 2, 3} B) x = [1, 2, 3] ✅ C) x = (1, 2, 3)

D) x = "1, 2, 3"

What built-in data type is used when you assign text to your variable?

str x = "Hello, World!" x = str("Hello, World!") What built-in data type is used when you assign a numeric value to your variable? int x = 20 x = int(20) float x = 20. x = float(20.5) compl ex x = 1j x = complex(1j) What built-in data type is used when you assign a sequence to your variable? list x = ["apple", "banana", "cherry"] 1

Page 3 of 51 bool x = True x = bool(5) What built-in data type is used when you assign binary to your variable? bytes x = b"Hello" x = bytes(5) bytearray x = bytearray(5) memoryview x = memoryview(bytes(5)) What built-in data type is used when you assign the value none to your variable? nonetyp e x = none print(10 > 9) print(10 == 9) print (10 < 9) Boolean print(bool("Hell o")) print(bool("15" ))

Page 4 of 51 Boolean examples of True print(bool(Fals e)) print( ) print(0) Boolean examples of False print(isinstance(x, int)) determine if an object is of a certain data type int( ) casts an integer from an integer literal, float literal, or string literal float( ) casts a float from an integer literal, a float literal, or a string literal str( ) casts a string from strings, integer literals, or a float literals print("text") outputs text to the console print("text", end=" ") print("more text") will end with a space and continue on the same line ("text more text") print("Wage", wage) 4

Page 5 of 51 comma will print both items with a space between them print(variable) prints the value of the variable print("1\n2\n3") print using newline characters print( ) print a blank line python file.py run a script file random function there is no random function, but there is a random module (import random) for x in "bananas": print(x) strings are arrays, so this will loop through the characters in "bananas" variable=input( ) assign text entered by the user to a variable; input is always a string variable = int(input) convert user input into an integer

Page 6 of 51 hourly_wage = int(input("Enter hourly wage: ")) display text prompt (Enter hourly wage) to request input from user and convert to integer print(a.upper( )) display a in console in upper case print(a.lower( )) display a in console as lower case print(a.strip( )) remove whitespace at beginning and end print(a.replace("H", "J")) replace a string with another string print(a.split("b")) split string at specified character c=a+ b print( c) concatenate (combine) two strings a=(f"My name is John, I am {age}") print(a) f-string; { } is the placeholder/modifier

Page 8 of 51 import sys print(sys.version) How do you edit, save, and run a Python file? edit = can edit in a text editor save = save as file.py run = in command prompt, type file.py Can you run Python in the Command Line? type python or py you will see Python version information and >>> when you are finished, type exit( ) What is unique about Python script formatting? relies on indentation (whitespace) to define scope instead of curly brackets Which Python datatypes are used to store arrays? list, tuple, set, and dictionary Which Python datatypes allow arrays with duplicates? list and tuple Which Python datatypes are for ordered arrays? list, tuple, dictionary Which Python datatypes are unchangeable? tuple and set 8

Page 9 of 51 What kind of variable would x = [ ] result in? list How do you determine how many items are in a list? print(len(yourlist)) What are some characteristics of a list? ordered; changeable; allows duplicate values; new values added to the end of the list; indexed (first value if 0, second value is 1, etc.); values can be any datatype (and a mix of datatypes) What are some characteristics of a tuple? ordered; unchangeable; allows duplicate values What are some characteristics of a set? unordered; unchangeable (you can add or remove items, but you cannot change an item); unindexed What are some characteristics of a dictationary? ordered; changeable; no duplicates How do you verify the type of an object? print(type(myobject)) What is an integer? positive or negative whole number of unlimited length What is a float? 9

Page 11 of 51 used to assign values to variables if x = 5 what is x += 3 8 if x = 5 what is x -= 2 3 *if x = 5 what is x = 3 15 if x = 5 what is x /= 3

if x = 5 what is x %= 3 2 if x = 5 what is x //= 3 1, which is assigned back to x **if x = 5 what is x = 3 11

Page 12 of 51 125, which is assigned back to x What does == mean? equal to What does != mean? not equal to What are the comparison operators? == != > < >= <= What are the logical operators? and, or, not What are the identity operators? is, is not What are the membership operators? in, not in What are the assignment operators? 12