Docsity

WGU D335 PYTHON PROGRAMMING EXAM SOLUTIONS 2025/2026, Quizzes of Programming Languages

Toggle sidebar
bg1
WGU D335 PYTHON PROGRAMMING EXAM
SOLUTIONS 2025/2026
Student Identification Number
A 9-digit unformatted integer input representing a student's ID.
Formatted Student ID Output
The output format for the student ID is <ssn>.
Input Validation for Student ID
The student ID must be between 100000000 and 999999999.
Formatted ID Construction
The formatted ID is constructed using parts derived from the student ID.
Predefined List
A list containing the values [4, -27, 15, 33, -10].
Boolean Value Output
Indicates whether the input value is greater than the maximum value from predef_list.
Max Value Calculation
The maximum value from predef_list is calculated using the max() function.
Frameworks List
A list of web frameworks: ['Django', 'Flask', 'CherryPy', 'Bottle', 'Web2Py', 'TurboGears'].
Index Value Input
An integer input representing the index of a string element in the frameworks list.
Exception Handling
A try block that raises an 'Error' for incompatible integer inputs.
Water Temperature Input
An integer input representing water temperature in degrees Fahrenheit.
Water State Description
Describes the state of water based on temperature ranges.
Frozen Water State
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download WGU D335 PYTHON PROGRAMMING EXAM SOLUTIONS 2025/2026 and more Quizzes Programming Languages in PDF only on Docsity!

WGU D335 PYTHON PROGRAMMING EXAM

SOLUTIONS 2025/

Student Identification Number A 9-digit unformatted integer input representing a student's ID. Formatted Student ID Output The output format for the student ID is . Input Validation for Student ID The student ID must be between 100000000 and 999999999. Formatted ID Construction The formatted ID is constructed using parts derived from the student ID. Predefined List A list containing the values [4, - 27, 15, 33, - 10]. Boolean Value Output Indicates whether the input value is greater than the maximum value from predef_list. Max Value Calculation The maximum value from predef_list is calculated using the max() function. Frameworks List A list of web frameworks: ['Django', 'Flask', 'CherryPy', 'Bottle', 'Web2Py', 'TurboGears']. Index Value Input An integer input representing the index of a string element in the frameworks list. Exception Handling A try block that raises an 'Error' for incompatible integer inputs. Water Temperature Input An integer input representing water temperature in degrees Fahrenheit. Water State Description Describes the state of water based on temperature ranges. Frozen Water State

Water is 'Frozen' if the temperature is below 33° F. Cold Water State Water is 'Cold' if the temperature is between 33° F and 80° F. Warm Water State Water is 'Warm' if the temperature is between 80° F and 115° F. Hot Water State Water is 'Hot' if the temperature is between 115° F and 211° F. Boiling Water State Water is 'Boiling' if the temperature is greater than or equal to 212° F. water_state Describes the state of water based on temperature. optional_safety_comment Safety comment displayed based on specific water temperatures. temperature The current temperature of the water. Frozen State of water when temperature is less than 33° F. Cold State of water when temperature is between 33° F and 80° F. Warm State of water when temperature is between 80° F and 115° F. Hot State of water when temperature is between 115° F and 212° F. Boiling State of water when temperature is 212° F or higher. Caution: Hot! Safety comment displayed when water temperature is exactly 212° F. Watch out for ice!

range() function Generates a sequence of numbers within a specified range. F strings Allows for easy formatting of strings in Python. dictionary Data structure with key-value pairs, where keys must be unique. name error The program tries to use a variable that does not exist. type error An operation uses incorrect types - can occur if adding an integer to a string. logic error (bug) Program runs but does the wrong thing. whitespace Any blank space or new line. = (assignment operator) Assigns a variable with a value. incrementing Increasing variables by a value of 1. float( ) A number with a decimal point. stocks {'TSLA': 912.86 , 'BBBY': 24.84, 'AAPL': 174.26, 'SOFI': 6.92, 'KIRK': 8.72, 'AURA': 22.12, 'AMZN': 141.28, 'EMBK': 12.29, 'LVLU': 2.33} purchase {"bananas": 1.85, "steak": 19.99, "cookies": 4.52, "celery": 2.81, "milk": 4.34} cost_of_stocks Total cost of the purchased shares of stock calculated from the stock selections. total_purchase_cost

Total cost of the grocery store items purchased, adjusted for discounts based on quantity. discount for 10-20 items If between ten and twenty items (inclusive) are purchased, the purchase gets a 5% discount. discount for 21 or more items If twenty-one or more items are purchased, the purchase gets a 10% discount. sentence A new sentence string composed of three existing words from a text file. file_name The name of a text file or CSV file input by the user. CSV file A file containing two rows of comma-separated values to be imported as dictionaries. num_stock An integer input identifying how many shares of stock are to be purchased. item_purchased A string input representing a grocery store item. num_items An integer input identifying the number of items purchased. Total price output format Output format for stock purchase: Total price: $cost_of_stocks Grocery purchase output format Output format for grocery purchase: item_purchased $total_purchase_cost File read and write Using open(), write(), and read() methods to interact with a text file. Dictionary creation from CSV Creating a dictionary of key:value pairs for each row of comma-separated values in a CSV file. Example of stock selection TSLA, BBBY, AAPL, SOFI, KIRK, AURA, AMZN, EMBK, LVLU

print( ) Displays output to the screen and starts a new line. # or """ Denotes a comment. string literal Text enclosed in quotes. end=' ' Keeps multiple print statements on one line. type( ) Determines how a value can behave. int( ) Converts string to an integer. syntaxes error A violation of the program language rules on how symbols can be defined. runtime error The program attempts an impossible operation. indentation error Lines inside the program are not properly indented. Value Error Invalid value used. input_pig_age An integer input representing the age of a pig. converted_pig_age The human equivalent age of a pig calculated using the pigAge_converter() function. Reverse Course A learning method involving video lectures at home and labs in class IPO thinking standard Input-Process-Output thinking standard to determine coding structure

name A special variable in Python that holds the name of the current module main A special variable in Python that indicates the main module Python Crash Course Book A resource for learning Python programming Public API's Application Programming Interfaces accessible to the public Pomodoro Technique Time management method using a timer to break work into intervals Dictionaries Data structure with key-value pairs used for mapping inputs to outputs CS An introductory course to computer science offered by Harvard University Merge Sort An efficient, comparison-based sorting algorithm Lists Ordered collection of items in Python denoted by square brackets Tuples Immutable ordered collection of items in Python denoted by parentheses Variables and Expressions Symbols used to represent values and perform operations Functions Blocks of organized, reusable code for specific tasks Lab Walkthroughs Guided demonstrations of critical programming exercises Arithmetic Operators Symbols used to perform mathematical operations in Python

List An ordered and changeable collection in Python allowing duplicates Set An unordered and immutable collection in Python, allowing addition/removal but no duplicates Tuple An ordered and unchangeable collection in Python, allowing duplicates and faster operations Immutable Unable to be changed, e.g., tuple elements Floor division Dividing integers to get the whole number part of the quotient Calories burned equation Estimates average calories burned based on age, weight, heart rate, and time Math functions Using math library for operations like power, absolute value, and square root Frequency calculation Calculating frequencies of keys on a piano based on initial key frequency Half-life Time taken for a substance to reduce to half its original value House real estate summary Outputting price change and estimated monthly mortgage based on current and last month's price Simple statistics Calculating product and average of floating-point numbers, rounding and formatting the output Northern hemisphere seasons Determining the season based on input date and month, considering days in each month Seasons

Spring: March 20 - June 20, Summer: June 21 - September 21, Autumn: September 22 - December 20, Winter: December 21 - March 19 Leap Year A year with 366 days, occurring every 4 years and divisible by 4, except for century years not divisible by 400 Interstate Highway Numbers Primary highways: 1-99, odd for north/south, even for east/west. Auxiliary: 100-999, servicing the rightmost two digits of the primary highway Golf Scores Score names: 'Eagle' (2 less than par), 'Birdie' (1 less), 'Par' (equals par), 'Bogey' (1 more); 'Error' if par not 3, 4, or 5 Conditional Statements Used for multiple choices. 'if' for an option, 'elif' for alternatives, 'else' as the final option if none apply Nested Loops Loops within loops, used for complex iterations and operations Nested Lists Lists within lists, used for organizing and managing complex data structures Range Function Returns a sequence of numbers, commonly used in for loops Smallest and Largest Numbers in a List Iterating through a list to find the smallest and largest values Append Method to add elements to the end of a list Break Statement Used to exit a loop based on a certain condition, instead of relying on the condition to become false Stub function A function that acts as a placeholder and returns a simple value so another function can be tested

Trapezoid Area Formula A = [(b1 + b2) / 2] * h area_value the exact area of the trapezoid calculated using the trapezoid area formula integer_sum_value sum of five inputs maintained as integer values float_sum_value sum of five inputs converted to float values string_sum_value sum of five inputs converted to string values (concatenate)