Limited-Time Offer: Enjoy 50% Savings! - Ends In 1d 2h 29m 0s Coupon code: 50OFF

WGU Foundations-of-Programming-Python Exam Questions & Answers (November 2026)

Foundations of Programming (Python) exam questions with 14 free practice questions and explained answers. Updated November 23, 2026. · See all WGU exams

Answer 14 scenario questions on this page and see your score as you go. No sign-up needed.

Exam Details

Exam Code
Foundations-of-Programming-Python
Vendor
WGU
Question Types
Single Choice
1

Variables, Data Types, and Basic Operations

This topic covers assigning values to variables, recognizing common Python data types, and using basic operations with those values. Candidates must be able to choose suitable types, perform arithmetic, and convert values when a calculation requires it.

Question 1 of 14 Single Choice

A repair company calculates labor charges from recorded work time. An analyst has the variables `minutes = 95` and `hourly_rate = 24.0`. The billing system requires the unrounded labor amount as a number, not as text. The analyst must account for all 95 minutes rather than counting only complete hours.

Which expression calculates the required labor amount as a numeric value?

Show Answer

Correct Answer

A

Option A is correct because `/` performs true division, so `24.0 * 95 / 60` evaluates to the numeric float `38.0`. Option B is not correct because `95 // 60` discards the remaining minutes before multiplication. Option C is not correct because `str` converts the result to text. Option D is not correct because it adds the hourly rate to the elapsed hours instead of multiplying by them.

Question 2 of 14 Single Choice

A small parts supplier stores the quantity and unit cost for a pending charge in two string variables, `quantity_text = '4'` and `unit_cost_text = '12.50'`. The accounting calculation must produce a numeric total of 50.0 so later arithmetic can use it. The stored values must remain available as strings for the supplier's existing display code.

Which expression produces the correct numeric total?

Show Answer

Correct Answer

A

Option A is correct because converting both strings to floats makes their product the numeric value `50.0`. Option B is not correct because `int` cannot convert the string `'12.50'`. Option C is not correct because Python cannot multiply two strings. Option D is not correct because string concatenation creates `'412.50'` before conversion, producing `412.5` rather than the required total.

Question 3 of 14 Single Choice

A support desk keeps a text label for each ticket. At the start of a review, `status` contains `'open'`, and the application saves its current value with `original_status = status`. The review step then runs `status = status + ' - reviewed'`. Later reporting needs both the original label and the updated label, without changing either statement.

Which statement accurately describes the values and types after the review step runs?

Show Answer

Correct Answer

A

Option A is correct because assigning the combined string back to `status` changes that variable, while `original_status` retains its earlier string value. Option B is not correct because the assignment does not update the separate variable. Option C reverses the two values. Option D is not correct because concatenating strings produces another string, not a list.

2

Control Flow and Decision Making

This topic covers how Python selects actions with if, elif, and else statements. Candidates must apply comparisons and logical operators to express rules clearly, including rules with alternative conditions and boundary values.

Question 4 of 14 Single Choice

A release-control service receives a text status from a build approval system. The production policy permits publishing only when the returned value is exactly the uppercase string CLEAR. Values REVIEW, BLOCKED, and lowercase clear must all prevent publication. A developer is choosing a Boolean condition for the existing decision branch, and the condition must not treat any alternate status as permission.

Which Boolean condition permits publication only for the required status?

Show Answer

Correct Answer

A

Option A is correct because equality with "CLEAR" allows only the exact status required by the production policy. Option B is not correct because it also permits REVIEW. Option C is not correct because a status cannot equal CLEAR and REVIEW at the same time. Option D is not correct because it also permits lowercase clear.

Question 5 of 14 Single Choice

A building access system allows a visitor to enter only with a valid badge and either a host who is present or an assigned after-hours escort. During a test, the visitor has an invalid badge, no host is present, and an escort is assigned. The developer is choosing a single Python condition for the entry approval branch, and the rule must remain correct when any of these facts change.

Which condition enforces the visitor entry rule for all combinations of these facts?

Show Answer

Correct Answer

A

Option A is correct because a valid badge is required, while either a present host or an assigned escort is sufficient. Option B is not correct because an escort could allow entry despite an invalid badge. Option C is not correct because it requires both a host and an escort. Option D is not correct because a valid badge alone would allow entry.

Question 6 of 14 Single Choice

A quality team at a packaging facility reviews batch audit scores before export. The policy allows automated release for a score of 80 or higher, while lower scores must be held for manual review. The dashboard must assign one of the exact labels "Ready" or "Manual review" using a single Python conditional expression.

Which expression meets the policy?

Show Answer

Correct Answer

A

Option A is correct because it returns "Ready" at the required boundary of 80 and for higher scores, and returns "Manual review" otherwise. Option B reverses the required labels. Option C incorrectly sends a score of exactly 80 to manual review. Option D is incomplete because a Python conditional expression must include an else expression.

3

Loops and Iteration

This topic covers repeated execution with for and while loops and iteration through strings and lists. Candidates must trace loop passes and determine how break and continue affect which items are processed.

Question 7 of 14 Single Choice

A warehouse script processes records in this order, READY, RETRY, PACKED, STOP, and SHIPPED. Its loop skips any record marked RETRY, stops as soon as it reaches STOP, and adds every other record to a processed-record list. The receiving team needs to verify which records the loop actually adds before approving the script.

Which sequence is added to the processed-record list?

Show Answer

Correct Answer

A

Option A is correct because the loop adds READY, skips RETRY, adds PACKED, and stops before adding STOP. Option B is not correct because RETRY is skipped. Option C is not correct because STOP is not added. Option D is not correct because the loop stops before reaching SHIPPED.

Question 8 of 14 Single Choice

A laboratory calibration script must perform a check on each pass, with no early exit or skipped passes. The cycle counter starts at 1, the loop repeats while the counter is less than 5, and the counter increases by 1 after each check. A technician wants to confirm how many checks this existing loop performs before changing its limit.

How many checks does the loop make before it ends?

Show Answer

Correct Answer

B

Option B is correct because the loop runs with cycle values 1, 2, 3, and 4, then ends when the value reaches 5 and no longer meets the less-than condition. Option A is not correct because it stops one pass too early. Option C and Option D are not correct because they exceed the stated loop boundary.

4

Functions and Modular Programming

This topic covers defining and calling functions, passing arguments, and using return values. Candidates must also trace name scope and reuse functions across Python modules.

Question 9 of 14 Single Choice

A support team uses a function named make_label that accepts a ticket ID and an optional area, which defaults to "Main". It returns a formatted label and does not print anything. A nightly support script must create a label for ticket T-42 in the Night area and store the returned text in a variable named ticket_label. The function signature must remain unchanged.

Which approach meets the team’s requirements?

Show Answer

Correct Answer

A

Option A is correct because it supplies the ticket ID as the first parameter, names the area parameter, and stores the function’s returned string. Option B reverses the parameter values. Option C prints the result instead of assigning the returned value. Option D supplies three arguments to a function that accepts only two.

Question 10 of 14 Single Choice

A reporting service sets a module-level service_fee to 12, and administrators may update that setting while the service is running. The function total_cost accepts one parameter named base, assigns a local service_fee value of 4, and returns base plus service_fee. Existing callers must keep using one argument, and the function must use the latest module setting without changing it.

Which change best meets the requirement?

Show Answer

Correct Answer

B

Option B is correct because removing the local assignment lets the function read the current module-level value without changing existing calls. Option A still assigns 4 and also changes the shared setting. Option C evaluates its default when the function is defined, so later configuration updates are not reflected. Option D displays a value but does not return it.

Question 11 of 14 Single Choice

A finance team maintains format_invoice in a file named billing_rules.py. Two reporting scripts in the same directory need identical invoice formatting, and maintainers require all formatting changes to be made in one place. The second script must call the shared function with an account ID and a billing period, then use the returned string in its own report.

Which approach lets the second script use the shared function and its returned string?

Show Answer

Correct Answer

A

Option A is correct because billing_rules is the module name and importing format_invoice makes that function available for a direct call. Option B reverses the module and function names. Option C imports the module but does not bind format_invoice as a direct name. Option D duplicates the implementation instead of reusing the shared module.

5

Data Structures and Input/Output

This topic covers choosing and using Python lists, tuples, and dictionaries, along with reading input and displaying output. Candidates must also select suitable file operations and process stored text without damaging existing data.

Question 12 of 14 Single Choice

A support desk keeps each customer's contact details in a Python dictionary. Some older records do not contain a phone key, and the display must show the text Not provided for those records. The application must leave every dictionary exactly as stored because another screen uses the original data.

Which expression should the application use to obtain the phone value without changing the profile dictionary?

Show Answer

Correct Answer

B

Option B returns the requested default when the optional phone key is absent, while leaving the profile unchanged. Option A raises a KeyError for the missing key. Option C inserts the default into the dictionary, which violates the requirement not to change it. Option D removes the key if it exists.

Question 13 of 14 Single Choice

A reception application runs in a terminal and asks each visitor for a badge name. The name must be stored exactly as entered, including any spaces at the beginning or end, but it must not contain the newline created when the visitor presses Enter. The program must display its own prompt as part of the input request.

Which expression should the program assign to the badge_name variable?

Show Answer

Correct Answer

A

Option A displays the required prompt and returns the entered line without its line-ending character, while preserving any other text as entered. Option B uses a different input interface and can retain the line ending. Option C removes leading and trailing whitespace. Option D displays the value but returns None, so it cannot provide the required stored name.

Question 14 of 14 Single Choice

A facilities team keeps a plain-text maintenance log that already contains several months of records. At the end of each shift, a small Python utility must add one new line to the same file. The utility must preserve all earlier entries, and the file is guaranteed to exist before the utility runs.

Which file mode should the program use?

Show Answer

Correct Answer

C

Option C is correct because append mode adds the new record after existing file contents and can open a file that already exists. Option A opens the file for reading, so it cannot write the record. Option B truncates existing contents. Option D creates a new file and fails when the named file already exists.

Continue Your Foundations-of-Programming-Python Preparation

You have seen 14 questions from a full set of 60. Prepare with the Foundations-of-Programming-Python dumps PDF and the Web-Based Practice Test.

PDF

  • Compatible with All Devices
  • Printable Format
  • No Download Limits

Practice Test

  • Check your timing and weak areas
  • No Practice Limits
  • Regularly Updated
Get Full Access
  • 100% Money-Back Guarantee
  • 90 Days Free Updates
  • Instant Access

Frequently Asked Questions

Which Python concepts tend to require the most careful reasoning?

Candidates can find boundary conditions in control flow surprisingly demanding. A condition using comparisons and logical operators may behave differently at an exact limit than it does just above or below it. Variable types and conversions also matter, since a calculation can produce an unintended result if values are not suitable for the operation. Practise tracing short examples by hand, and write down the value and type of each variable after every step.

Why can tracing loops through lists and strings be difficult?

A loop question can require you to track the current item, the condition, and the effect of break or continue in the same trace. With a while loop, it is also easy to miss how an update affects whether the loop runs again. Work through each pass in order, recording the item processed and any change to variables. Include a case where break stops iteration and one where continue skips only the current pass.

Why do simple programs still produce unexpected results during practice?

A frequent source of trouble is mixing input, types, and arithmetic. Input read from a user may need conversion before it can be used in a calculation, while an incorrect conversion can cause an error or an unintended result. It is tempting to focus only on the arithmetic. Use the Exam4Success PDF to review examples away from a coding environment, then practise identifying each value's type before calculating.

What makes file input and output harder to prepare for than it first appears?

Reading and writing files involves more than displaying text. Candidates need to choose an appropriate file operation and consider whether an operation will preserve or replace existing content. That distinction is easy to overlook when focusing on the processing logic. Before practising, write down what the program should read, what it should produce, and whether existing text must remain. Use the Exam4Success PDF to revisit the topic when access to a coding environment is limited.

What practical foundation should candidates hope to build from this exam?

The topics provide a foundation for reading and writing small Python programs. Candidates practise representing values, expressing decisions, repeating work, organizing code into functions, and handling collections and text input or output. These skills can help make later programming study more approachable, though this exam alone does not establish readiness for a particular job or advanced certification. As you prepare, build a small program that uses a function, a loop, and a list together.

How can the functions and data structure topics support further Python learning?

Functions, lists, tuples, and dictionaries introduce ways to organize code and related information rather than placing every instruction in one sequence. Understanding arguments, return values, and name scope also helps when you begin working with larger programs or separate modules. The value is a usable base for further practice, not a guarantee of a specific next credential. To reinforce it, write one function that accepts a collection and returns a useful result.

How can I judge whether I am ready to move beyond basic review?

Readiness is clearer when you can explain a program's behavior without relying on memorized patterns. Check that you can trace a loop, evaluate an if and elif chain at boundary values, and identify what a function returns. The Exam4Success Practice Test can help you check timing and identify weak areas. After using it, review missed topics and try a fresh example before deciding which subject needs more work.

What should I study first if I am new to Python?

Start with variables, common data types, arithmetic, and conversions. These ideas appear again when you handle input, write conditions, and process collections, so gaps here can make later topics feel confusing. Then study control flow before moving to loops, functions, and file operations. The Exam4Success PDF can support review between coding sessions. After each topic, write a short example and trace its values rather than only rereading explanations.

Exam4Success is an independent exam preparation provider and is not affiliated with or endorsed by WGU.