

























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 65
This page cannot be seen from the preview
Don't miss anything!


























































Page 1 of 51
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:
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