D335 Introduction to Programming in Python –Real Study Guide – WGU – 2026/2027 | Fully s, Exams of Network Programming

ACE and PASS the WGU D335 Introduction to Programming in Python Exam (2026) with this high-yield, instant PDF download featuring actual exam questions and complete step-by-step solutions. Designed for first-time test-takers and retakes, this guide covers all essential Python topics including variables, data types, loops, conditionals, functions, modules, lists, dictionaries, file I/O, exception handling, and basic object-oriented programming. With verified solutions for every question, this ready-to-use resource ensures efficient study, strong concept mastery, and the confidence to pass your exam on the first attempt, making it perfect for WGU Computer Science, Software Development, and IT students.

Typology: Exams

2025/2026

Available from 01/27/2026

studyguidepro
studyguidepro 🇺🇸

4

(1)

340 documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
D335 Introduction to Programming in
Python Real Study Guide WGU
2026/2027 | Fully solved Exam
How are most Python programs developed?
Writing code in files - The Python interpreter can load and
execute Python code saved in files string literal text enclosed in
quotes, may have letters, numbers, spaces , or symbols.
Given the variable num_cars = 9, which statement prints 9?
print(num_cars)
newline character
"\n" moves output to the next line
Whitspace
Any space, tab or newline
Input function
Causes the interpreter to wait until the user has entered
some text and has pushed the return key string
It simply represents a sequence of characters.
Which statement reads a user-entered string into variable
num_cars?
num_cars = input ()
Type
Determines how a value can behave. For example, integers can
be divided by 2, but not strings ex 'Hello' int function
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download D335 Introduction to Programming in Python –Real Study Guide – WGU – 2026/2027 | Fully s and more Exams Network Programming in PDF only on Docsity!

D335 Introduction to Programming in

Python – Real Study Guide – WGU –

2026/2027 | Fully solved Exam

How are most Python programs developed? Writing code in files - The Python interpreter can load and execute Python code saved in files string literal text enclosed in quotes, may have letters, numbers, spaces , or symbols. Given the variable num_cars = 9, which statement prints 9? print(num_cars) newline character "\n" moves output to the next line Whitspace Any space, tab or newline Input function Causes the interpreter to wait until the user has entered some text and has pushed the return key string It simply represents a sequence of characters. Which statement reads a user-entered string into variable num_cars? num_cars = input () Type Determines how a value can behave. For example, integers can be divided by 2, but not strings ex 'Hello' int function

can be used to convert that string to the integer for numbers Type a statement that converts the string '15' to an integer and assigns my_var with the result. my_var = int('15") syntax error An error that results when an instruction does not follow the syntax rules or grammar of the programming language. Runtime error An error that occurs when the program is run using certain sets of data that result in some illegal operation, such as dividing by zero. Crash runtime error halts the execution of the program. Abrupt and unintended termination of a program logic error errors may be subtle enough to silently misbehave, instead of causing a runtime error and a crash. An example might be if a programmer accidentally typed "2 4" rather than "2 40" - the program would load correctly, but would not behave as intended Bug Is also called logic error Integrated Development Environment (IDE) Provides a developer with a way to create a program, run the program, and debug the program all within one application. Application another word for a program or software Compiler

Python object has three defining properties: value, type, and identity. Identity A unique identifier that describes the object. Mutability indicates whether the object's value is allowed to be changed Immutable unchangeable such as integers and strings Id() that gives the value of an object's identity floating point numbers Numbers where the decimal point can float because there is no fixed number of digits before and after the decimal point. AKA: real numbers The number of cars in a parking lot. int The current temperature in Celsius. float A person's height in centimeters. float The number of hairs on a person's head. int The average number of kids per household. int

Which of the following arguments completes print() to output two digits after the decimal point?print(f'{(7.0 / 3.0)_____) print(f'{(7.0/3.0):.2f}') outputs 2.33. What is output by print(f'{0.125:.1f}')? print(f'{0.125:.1f}') outputs the value with one digit after the decimal point. What is output by print(f'{9.1357:.3f}')? print(f'{9.1357:.3f}') outputs 9.136 because the third digit after the decimal point is rounded. ( ) Items within parentheses are evaluated first. In 2 * (x + 1), the x + 1 is evaluated first, with the result then multiplied by 2. **exponent ****

  • used for exponent is next. In xy 3, x to the power of y is computed first, with the results then multiplied by 3. unary -
  • used for negation (unary minus) is next. In 2 * - x, the - x is computed first, with the result then multiplied by 2. The floor division operator // can be used to round down the result of a floating-point division to the closest smaller whole number value. modulo operator (%) evaluates the remainder of the division of two integer operands. Ex: 23 % 10 is 3. Given a non-negative number x, which expression has the range 5 to 10? % 6 yields 0 to 5. Then + 5 yields 5 to 10.

Write a statement that prints the length of the string variable first_name. print(len(first_name)) brackets [] [ ], grouping symbols, A pair of symbols used to enclose sections of an expression. What character is in index 2 of the string "America"? The first character "A" has index 0, "m" has index 1, and index 2 is "e". Write an expression that accesses the first character of the string my_country. my_country[0] Assign my_var with the last character in my_str. Use a negative index my_var = my_str[-1] String concatenation A program can add new characters to the end of a string in a process Container A construct used to group related values together and contains references to other objects instead of data List A container created by surrounding a sequence of variables or literals with brackets [ ]. Ex: my_list = [10, 'abc'] creates a new list variable my_list that contains the two items: 10 and 'abc' Element A list of item

Element's Index A list is also a sequence, meaning the contained elements are ordered by position in the list Write a statement that creates a list called my_nums, containing the elements 5, 10, and 20. my_nums = [5, 10, 20] Write a statement that creates a list called my_list with the elements - 100 and the string 'lists are fun'. my_list = [-100, 'lists are fun'] Write a statement that creates an empty list called class_grades. class_grades = [] Lists Are useful for reducing the number of variables in a program. Instead of having a separate variable for the name of every student in a class, or for every word in an email, a single list can store an entire collection of related variables. Write a statement that assigns my_var with the 3rd element of my_list. my_var = my_list[2] Write a statement that assigns the 2nd element of my_towns with 'Detroit'. my_towns[1] = 'Detroit' Method instructs an object to perform some action, and is executed by specifying the method name following a "." symbol and an object.

Create a new variable point that is a tuple containing the strings 'X string' and 'Y string'. Use parentheses to create new tuples. point= (?) Named tuple allows the programmer to define a new simple data type that consists of named attributes Create a new named tuple Dog that has the attributes name, breed, and color. Dog = namedtuple('Dog', ['name', 'breed', 'color']) Let Address = namedtuple('Address', ['street', 'city', 'country']). Create a new address object house where house.street is "221B Baker Street", house.city is "London", and house.country is "England". house = Address('221B Baker Street', 'London', 'England') Given the following named tuple Car = namedtuple('Car', ['make', 'model', 'price', 'horsepower', 'seats']), and data objects car1 and car2, write an expression that computes the sum of the price of both cars. car1.price + car2.price Add the literal 'Ryder' to the set names. names.add('Ryder') Add all of the elements of set goblins into set monsters. Remove all of the elements from the trolls set. trolls.clear() set.intersection Returns a new set containing only the elements in common between set and all provided sets. set.union

Returns a new set containing all of the unique elements in all sets. set.difference Returns a set containing only the elements of set that are not found in any of the provided sets. set_a.symmetric_difference Returns a set containing only elements that appear in exactly one of set_a or set_b Use braces to create a dictionary called ages that maps the names 'Bob' and 'Frank' to their ages, 27 and 75, respectively. For this exercise, make 'Bob' the first entry in the dict. {'Bob': 27, 'Frank': 75} A dictionary entry is accessed by placing a key in curly braces { }. A key is placed in brackets [ ] to access a specific dictionary entry. Curly braces { } are used to build a dictionary. Dictionary entries are ordered by position. As of Python 3.7, the standard is for dictionaries to maintain their left-right insertion order. Though ordered, dictionary entries cannot be accessed by indexing. Which statement adds 'pears' to the following dictionary? prices['pears'] = 1. Sequence types

a type conversion automatically made by the interpreter, usually between numeric types formatted string literal, or f-string allows a programmer to create a string with placeholder expressions that are evaluated as the program executes replacement field A placeholder surrounded by curly braces { } I need 3 items please print(f'I need {num_items} items please') The f-string begins with an f character before the first quote. The single replacement field, {num_items}, is evaluated when the program is run, and is assigned with the value 3. 3 tacos cost 3. print(f'{num_items} tacos cost {cost_taco * num_items}') A replacement field can contain almost any expression, including multiplication of two variables to calculate the total cost. Format specifications inside a replacement field allows a value's formatting in the string to be customized. A format specification is introduced with a colon : presentation type is a part of a format specification that determines how to represent a value in text form, such as integer (4), floating point (4.0), fixed precision decimal (4.000), percentage (4%), binary (100), etc. branch a sequence of statements only executed under a certain condition.

if branch A branch taken only if an expression is true. If-else branches has two branches: The first branch is executed IF an expression is true, ELSE the other branch is executed. If-elseif-else branches Commonly a programmer wishes to take one of multiple (three or more) branches. An if-else can be extended to an if-elseif-else structure. Each branch's expression is checked in sequence; as soon as one branch's expression is found to be true, that branch is taken. If no expression is found true, execution will reach the else branch, which then executes. Boolean a type that has just two values: True or False. inequality operator (!=) evaluates to true if the left and right sides are not equal, or different. If user_age equals 62, assign item_discount with 15. Else, assign item_discount with 0. if user_age == 62: item_discount = 15 else: item_discount = 0

The standard number of spaces to use for indentation is 4. PEP8 suggests 4 spaces. A programmer can start new code blocks at any point in the code, as long as the indentation for each line in the block is consistent. New code blocks may only begin after a statement that ends with a colon ":", such as "if" or "else". ternary operation A conditional expression has three operands Using a conditional expression, write a statement that increments num_users if update_direction is 3, otherwise decrements num_users. Sample output with inputs: 8 3 New value is: 9 num_users = int(input()) update_direction = int(input()) num_users = num_users + 1 if update_direction == 3 else num_users - 1 print('New value is:', num_users) A learning method involving video lectures at home and labs in class Reverse Course Input-Process-Output thinking standard to determine coding structure IPO thinking standard

A special variable in Python that holds the name of the current module name A special variable in Python that indicates the main module main A resource for learning Python programming Python Crash Course Book 🐍 Application Programming Interfaces accessible to the public Public API's Time management method using a timer to break work into intervals Pomodoro Technique Data structure with key-value pairs used for mapping inputs to outputs Dictionaries An introductory course to computer science offered by Harvard University CS An efficient, comparison-based sorting algorithm Merge Sort Ordered collection of items in Python denoted by square brackets Lists Immutable ordered collection of items in Python denoted by parentheses

An educational coding platform for honing programming skills Codewars An online platform offering data science and analytics courses Data Camp A comprehensive course for learning Python programming Springboard Python course A program that translates Python code into machine code Python compiler Extracting a portion of a sequence like a string or list in Python Slicing A notable resource for learning programming through tutorials and guides Corey Schaefer A collection of programming tutorials and resources Bro Code Playlist Converting a value to a different data type, e.g., int('1') returns 1 as an integer Type conversion/casting Enforcing order of operations using parentheses, e.g., 3 * (2+1) = 9 Precedence Using type() to find the data type of a variable or value

Data type check An ordered and changeable collection in Python allowing duplicates List An unordered and immutable collection in Python, allowing addition/removal but no duplicates Set An ordered and unchangeable collection in Python, allowing duplicates and faster operations Tuple Unable to be changed, e.g., tuple elements Immutable Dividing integers to get the whole number part of the quotient Floor division Estimates average calories burned based on age, weight, heart rate, and time Calories burned equation Using math library for operations like power, absolute value, and square root Math functions Calculating frequencies of keys on a piano based on initial key frequency Frequency calculation Time taken for a substance to reduce to half its original value