WGU D335 Practice Test 2 (Introduction to Programming in Python) PA | Actual Questions and, Exams of Programming Languages

WGU D335 Practice Test 2 (Introduction to Programming in Python) PA | Actual Questions and Answers | 2026 Update | 100% Correct. This WGU D335 (Introduction to Programming in Python) Practice Test 2 is a crucial resource because it is nearly identical to the actual Objective Assessment (OA). Exam Description The assessment is a proctored, code-writing exam (performance-based OA) rather than a multiple-choice test. Format: 15 coding questions where you must write a complete solution in a Python environment. Practice Test 2: Key Topics & Study Guide This Practice Test 2 (found in the final chapters of the ZyBooks material) covers the primary programming patterns you will encounter on the OA. Input/Output Formatting: Using. format() or f-strings for precise output (e.g., forcing two decimal places for currency). Specific formatting for items like Social Security Numbers or Boolean values. Core Logic & Math:

Typology: Exams

2025/2026

Available from 02/22/2026

ExamPage
ExamPage 🇺🇸

4

(20)

3.8K documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
WGU D335 Practice Test 2 (Introduction to
Programming in Python) PA | Actual
Questions and Answers | 2026 Update | 100%
Correct.
This WGU D335 (Introduction to Programming in Python) Practice Test 2 is a crucial
resource because it is nearly identical to the actual Objective Assessment (OA).
Exam Description
The assessment is a proctored, code-writing exam (performance-based OA) rather than a
multiple-choice test.
Format:
15 coding questions where you must write a complete solution in a Python environment.
Practice Test 2: Key Topics & Study Guide
This Practice Test 2 (found in the final chapters of the ZyBooks material) covers the primary
programming patterns you will encounter on the OA.
Input/Output Formatting:
Using. format() or f-strings for precise output (e.g., forcing two decimal places for currency).
Specific formatting for items like Social Security Numbers or Boolean values.
Core Logic & Math:
Using floor division (//) and modulus (%) for unit conversions (e.g., converting total ounces
into tons, pounds, and remaining ounces).
Calculating areas (e.g., trapezoid area) and basic geometric formulas.
Data Structures:
Lists and Dictionaries: Accessing elements by index, using zip() to pair lists into a dictionary,
and iterating through rows of data.
Slicing: Understanding start/end indices for string or list slicing.
File Handling & Modules:
Reading/Writing Files: Using open() with read(), readline(), and write() methods to
manipulate .txt files.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download WGU D335 Practice Test 2 (Introduction to Programming in Python) PA | Actual Questions and and more Exams Programming Languages in PDF only on Docsity!

WGU D335 Practice Test 2 (Introduction to

Programming in Python) PA | Actual

Questions and Answers | 202 6 Update | 100%

Correct.

This WGU D335 (Introduction to Programming in Python) Practice Test 2 is a crucial resource because it is nearly identical to the actual Objective Assessment (OA). Exam Description The assessment is a proctored, code-writing exam (performance-based OA) rather than a multiple-choice test. Format: 15 coding questions where you must write a complete solution in a Python environment. Practice Test 2: Key Topics & Study Guide This Practice Test 2 (found in the final chapters of the ZyBooks material) covers the primary programming patterns you will encounter on the OA. Input/Output Formatting: Using. format() or f-strings for precise output (e.g., forcing two decimal places for currency). Specific formatting for items like Social Security Numbers or Boolean values. Core Logic & Math: Using floor division (//) and modulus (%) for unit conversions (e.g., converting total ounces into tons, pounds, and remaining ounces). Calculating areas (e.g., trapezoid area) and basic geometric formulas. Data Structures: Lists and Dictionaries: Accessing elements by index, using zip() to pair lists into a dictionary, and iterating through rows of data. Slicing: Understanding start/end indices for string or list slicing. File Handling & Modules: Reading/Writing Files: Using open() with read(), readline(), and write() methods to manipulate .txt files.

CSV Module: Importing csv and using csv.reader to parse comma-separated data into usable lists. Math Module: Mastering basic functions within the Python math library. (Introduction to Programming in Python) (Ultimate guide for YR. 2026/2027) Quiz_________________? Create a solution that accepts an input identifying the name of a text file, for example, "WordTextFile1.txt". Each text file contains three rows with one word per row. Using the open() function and write() and read() methods, interact with the input text file to write a new sentence string composed of the three existing words to the end of the file contents on a new line. Output the new file contents.

  • Answer file_name = input() with open(file_name, 'r') as f: word1 = str(f.readline()).strip() word2 = str(f.readline()).strip() word3 = str(f.readline()).strip() f = open(file_name, 'r') lines = f.read().splitlines() lines = ' '.join(lines) f.close() print(f'{word1}\n{word2}\n{word3}\n{lines}') Quiz_________________?

data = [row for row in csv.reader(f)] for row in data: even = [row[i].strip() for i in range(0, len(row), 2)] odd = [row[i].strip() for i in range(1, len(row), 2)] pair = dict(zip(even, odd)) print(pair) Quiz_________________? Create a solution that accepts an integer input representing the index value for any any of the five elements in the following list: various_data_types = [516, 112.49, True, "meow", ("Western", "Governors", "University"), {"apple": 1, "pear": 5}] Using the built-in function type() and getting its name by using the .name attribute, output data type (e.g., int", "float", "bool", "str") based on the input index value of the list element. - Answer index_value = int(input()) name = various_data_types[index_value] data_type = type(name).name print(f"Element {index_value}: {data_type}") Quiz_________________? Create a solution that accepts an integer input. Import the built-in module math and use its factorial() method to calculate the factorial of the integer input.

Output the value of the factorial, as well as a Boolean value identifying whether the factorial output is greater than 100. - Answer import math fact = int(input()) x = math.factorial(fact) print(x) if x > 100: print('True') else: print('False') Quiz_________________? Create a solution that accepts any three integer inputs representing the base (b1, b2) and height (h) measurements of a trapezoid in meters. Output the exact area of the trapezoid in square meters as a float value. The exact area of a trapezoid can be calculated by finding the average of the two base measurements, then multiplying by the height measurement. Trapezoid Area Formula:A = [(b1 + b2) / 2] * h - Answer b1 = int(input()) b2 = int(input()) h = int(input()) area_value = ((b1 + b2) /2) * h print('Trapezoid area: {:.1f} square meters'.format(area_value))

num4 = int(input()) num5 = int(input()) first_output = num1 + num2 + num3 + num4 + num second_output = float(num1) + float(num2) + float(num3) + float(num4) + float(num5) third_output = str(num1) + str(num2) + str(num3) + str(num4) + str(num5) print('Integer: {}'.format(first_output)) print('Float: {}'.format(second_output)) print('String: {}'.format(third_output)) Quiz_________________? Create a solution that accepts a string input representing a grocery store item and an integer input identifying the number of items purchased on a recent visit. The following dictionary purchase lists available items as the key with the cost per item as the value. purchase = {"bananas": 1.85, "steak": 19.99, "cookies": 4.52, "celery": 2.81, "milk": 4.34} Additionally, If fewer than ten items are purchased, the price is the full cost per item. If between ten and twenty items (inclusive) are purchased, the purchase gets a 5% discount. If twenty-one or more items are purchased, the purchase gets a 10% discount. Output the chosen item and total cost of the purchase to two decimal places. - Answer store_item = input() num_items = int(input())

total_cost = purchase[store_item] * num_items if num_items < 10: print(store_item, "${:.2f}".format(total_cost)) if num_items in range(10,21): discount = total_cost * 0. total_cost = total_cost - discount print(store_item, '${:.2f}'.format(total_cost)) if num_items >= 21: discount = total_cost * 0. total_cost = total_cost - discount print(store_item, '${:.2f}'.format(total_cost)) Quiz_________________? Create a solution that accepts an integer input representing a 9-digit unformatted student identification number. Output the identification number as a string with no spaces. - Answer student_id = int(input()) student_id_string = str(student_id) first3 = student_id_string[0:3] second2 = student_id_string[3:5] third4 = student_id_string[5:] print(f'{first3}-{second2}-{third4}')

boolean_value = False max_value = max(predef_list) if num > max_value: boolean_value = True print('Greater Than Max? {}'.format(boolean_value)) else: print('Greater Than Max? {}'.format(boolean_value)) Quiz_________________? Create a solution that accepts an integer input representing water temperature in degrees Fahrenheit. Output a description of the water state based on the following scale: If the temperature is below 33° F, the water is "Frozen". If the water is between 33° F and 80° F (including 33), the water is "Cold". If the water is between 80° F and 115° F (including 80), the water is "Warm". If the water is between 115° F and 211° (including 115) F, the water is "Hot". If the water is greater than or equal to 212° F, the water is "Boiling". Additionally, output a safety comment only during the following circumstances: If the water is exactly 212° F, the safety comment is "Caution: Hot!" If the water temperature is less than 33° F, the safety comment is "Watch out for ice!" - Answer temperature = int(input()) if temperature <33: print('Frozen')

print('Watch out for ice!') if temperature in range(33, 80): print('Cold') if temperature in range(80, 115): print('Warm') if temperature in range(115, 211): print('Hot') if temperature >= 212: print('Boiling') if temperature == 212: print('Caution: Hot!') Quiz_________________? Create a solution that accepts one integer input representing the index value for any of the string elements in the following list: frameworks = ["Django", "Flask", "CherryPy", "Bottle", "Web2Py", "TurboGears"] Output the string element of the index value entered. The solution should be placed in a try block and implement an exception of "Error" if an incom mypatible integer input is provided - Answer index_value = int(input()) try: if index_value == 0: print(frameworks[0]) if index_value == 1: