Docsity

WGU C859 PYTHON TEST 78 FULL SOLUTION STUDY GUIDE, Exams of Programming Paradigms

Toggle sidebar
bg1
WGU C859 PYTHON TEST 78 PRACTICE
QUESTIONS AND TESTED SOLUTIONS
ā—‰ Frameworks List.
Answer: A list of web frameworks: ['Django', 'Flask', 'CherryPy',
'Bottle', 'Web2Py', 'TurboGears'].
ā—‰ Index Value Input.
Answer: An integer input representing the index of a string element
in the frameworks list.
ā—‰ Exception Handling.
Answer: A try block that raises an 'Error' for incompatible integer
inputs.
ā—‰ Water Temperature Input.
Answer: An integer input representing water temperature in
degrees Fahrenheit.
ā—‰ Water State Description.
Answer: Describes the state of water based on temperature ranges.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download WGU C859 PYTHON TEST 78 FULL SOLUTION STUDY GUIDE and more Exams Programming Paradigms in PDF only on Docsity!

WGU C859 PYTHON TEST 78 PRACTICE

QUESTIONS AND TESTED SOLUTIONS

ā—‰ Frameworks List. Answer: A list of web frameworks: ['Django', 'Flask', 'CherryPy', 'Bottle', 'Web2Py', 'TurboGears']. ā—‰ Index Value Input. Answer: An integer input representing the index of a string element in the frameworks list. ā—‰ Exception Handling. Answer: A try block that raises an 'Error' for incompatible integer inputs. ā—‰ Water Temperature Input. Answer: An integer input representing water temperature in degrees Fahrenheit. ā—‰ Water State Description. Answer: Describes the state of water based on temperature ranges.

ā—‰ Frozen Water State. Answer: Water is 'Frozen' if the temperature is below 33° F. ā—‰ Cold Water State. Answer: Water is 'Cold' if the temperature is between 33° F and 80° F. ā—‰ Warm Water State. Answer: Water is 'Warm' if the temperature is between 80° F and 115° F. ā—‰ Hot Water State. Answer: Water is 'Hot' if the temperature is between 115° F and 211° F. ā—‰ Boiling Water State. Answer: Water is 'Boiling' if the temperature is greater than or equal to 212° F. ā—‰ water_state. Answer: Describes the state of water based on temperature. ā—‰ optional_safety_comment.

ā—‰ Caution: Hot!. Answer: Safety comment displayed when water temperature is exactly 212° F. ā—‰ Watch out for ice!. Answer: Safety comment displayed when water temperature is less than 33° F. ā—‰ Reverse Binary. Answer: Representing an integer in reverse binary by outputting remainders of division by 2. ā—‰ name == 'main'. Answer: Used to separate the main code from the function's code for unit testing. ā—‰ Driving Cost Function. Answer: Function taking miles per gallon, price per gallon, and miles driven to return the dollar cost. ā—‰ Coin Flip Function.

Answer: Function returning 'Heads' or 'Tails' based on a random value of 1 or 0. ā—‰ Unit Tests. Answer: Testing small parts of a program in an isolated manner to ensure they work as expected. ā—‰ Unit test. Answer: Evaluates individual functions for correctness and proper naming, parameters, and return type. ā—‰ kilo_to_pounds(). Answer: Function that converts weight in kilograms to pounds. ā—‰ swap_values. Answer: Function that swaps the positions of four integers. ā—‰ check_integer_string. Answer: Function that checks if a string represents an integer. ā—‰ Mad Libs. Answer: Activity where user provides words to complete a story in unexpected ways.

Answer: The program tries to use a variable that does not exist. ā—‰ type error. Answer: An operation uses incorrect types - can occur if adding an integer to a string. ā—‰ logic error (bug). Answer: Program runs but does the wrong thing. ā—‰ whitespace. Answer: Any blank space or new line. ā—‰ = (assignment operator). Answer: Assigns a variable with a value. ā—‰ incrementing. Answer: Increasing variables by a value of 1. ā—‰ float( ). Answer: A number with a decimal point. ā—‰ stocks.

Answer: {'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. Answer: {"bananas": 1.85, "steak": 19.99, "cookies": 4.52, "celery": 2.81, "milk": 4.34} ā—‰ cost_of_stocks. Answer: Total cost of the purchased shares of stock calculated from the stock selections. ā—‰ total_purchase_cost. Answer: Total cost of the grocery store items purchased, adjusted for discounts based on quantity. ā—‰ discount for 10-20 items. Answer: If between ten and twenty items (inclusive) are purchased, the purchase gets a 5% discount. ā—‰ discount for 21 or more items. Answer: If twenty-one or more items are purchased, the purchase gets a 10% discount.

Answer: Output format for stock purchase: Total price: $cost_of_stocks ā—‰ Grocery purchase output format. Answer: Output format for grocery purchase: item_purchased $total_purchase_cost ā—‰ File read and write. Answer: Using open(), write(), and read() methods to interact with a text file. ā—‰ Dictionary creation from CSV. Answer: Creating a dictionary of key:value pairs for each row of comma-separated values in a CSV file. ā—‰ Example of stock selection. Answer: TSLA, BBBY, AAPL, SOFI, KIRK, AURA, AMZN, EMBK, LVLU ā—‰ Example of grocery items. Answer: bananas, steak, cookies, celery, milk ā—‰ Output new file contents. Answer: The contents of the file after appending the new sentence.

ā—‰ Cost per item. Answer: The cost assigned to each grocery item in the purchase dictionary. ā—‰ Cost per stock selection. Answer: The cost assigned to each stock in the stocks dictionary. ā—‰ factorial() method. Answer: A method from the math module used to calculate the factorial of an integer. ā—‰ input. Answer: A function used to get text from user. ā—‰ variable. Answer: A named item used to hold a value. ā—‰ Algorithm. Answer: Sequence of instructions that solves a problem. ā—‰ python interpreter or IDE.

ā—‰ string literal. Answer: Text enclosed in quotes. ā—‰ end=' '. Answer: Keeps multiple print statements on one line. ā—‰ type( ). Answer: Determines how a value can behave. ā—‰ int( ). Answer: Converts string to an integer. ā—‰ syntaxes error. Answer: A violation of the program language rules on how symbols can be defined. ā—‰ runtime error. Answer: The program attempts an impossible operation. ā—‰ indentation error. Answer: Lines inside the program are not properly indented.

ā—‰ Value Error. Answer: Invalid value used. ā—‰ input_pig_age. Answer: An integer input representing the age of a pig. ā—‰ converted_pig_age. Answer: The human equivalent age of a pig calculated using the pigAge_converter() function. ā—‰ Reverse Course. Answer: A learning method involving video lectures at home and labs in class ā—‰ IPO thinking standard. Answer: Input-Process-Output thinking standard to determine coding structure ā—‰ name. Answer: A special variable in Python that holds the name of the current module

Answer: An efficient, comparison-based sorting algorithm ā—‰ Lists. Answer: Ordered collection of items in Python denoted by square brackets ā—‰ Tuples. Answer: Immutable ordered collection of items in Python denoted by parentheses ā—‰ Variables and Expressions. Answer: Symbols used to represent values and perform operations ā—‰ Functions. Answer: Blocks of organized, reusable code for specific tasks ā—‰ Lab Walkthroughs. Answer: Guided demonstrations of critical programming exercises ā—‰ Arithmetic Operators. Answer: Symbols used to perform mathematical operations in Python

ā—‰ Comparisons. Answer: Operations that return true or false based on the comparison of values ā—‰ Absolute value function. Answer: Function to obtain the magnitude of an integer, removing the negative sign ā—‰ Round function. Answer: Function to round a value to a specified number of digits after the decimal point ā—‰ Iteration Statements. Answer: Statements used for repeated execution of instructions in a program ā—‰ Codewars. Answer: An educational coding platform for honing programming skills ā—‰ Data Camp.

ā—‰ Precedence. Answer: Enforcing order of operations using parentheses, e.g., 3 * (2+1) = 9 ā—‰ Data type check. Answer: Using type() to find the data type of a variable or value ā—‰ List. Answer: An ordered and changeable collection in Python allowing duplicates ā—‰ Set. Answer: An unordered and immutable collection in Python, allowing addition/removal but no duplicates ā—‰ Tuple. Answer: An ordered and unchangeable collection in Python, allowing duplicates and faster operations ā—‰ Immutable. Answer: Unable to be changed, e.g., tuple elements

ā—‰ Floor division. Answer: Dividing integers to get the whole number part of the quotient ā—‰ Calories burned equation. Answer: Estimates average calories burned based on age, weight, heart rate, and time ā—‰ Math functions. Answer: Using math library for operations like power, absolute value, and square root ā—‰ Frequency calculation. Answer: Calculating frequencies of keys on a piano based on initial key frequency ā—‰ Half-life. Answer: Time taken for a substance to reduce to half its original value ā—‰ House real estate summary. Answer: Outputting price change and estimated monthly mortgage based on current and last month's price