[Aug-2026] Latest WGU Foundations-of-Programming-Python exam dumps and online Test Engine [Q21-Q45]

5/5 - (2 votes)

[Aug-2026] Latest WGU Foundations-of-Programming-Python exam dumps and online Test Engine

WGU Foundations-of-Programming-Python: Selling Courses and Certificates Products and Solutions

WGU Foundations-of-Programming-Python Exam Syllabus Topics:

Section Objectives
Topic 1: File Handling and Exceptions – Exception handling (try/except)
– Reading and writing files
Topic 2: Debugging and Testing Basics – Error identification and correction
– Basic testing concepts
Topic 3: Control Flow – Loops (for, while)
– Conditional statements (if / elif / else)
Topic 4: Python Programming Fundamentals – Variables and data types
– Operators and expressions
– Syntax and basic structure
Topic 5: Data Structures – Lists, tuples, dictionaries
– Basic data manipulation
Topic 6: Functions and Modularity – Modules and imports
– Function definition and scope
Topic 7: Introduction to Object-Oriented Programming – Basic OOP concepts
– Classes and objects

 

Q21. Complete the function format_name(first, last) that takes a first name and last name and returns them combined as ” last, first ” .
For example, format_name( ” John ” , ” Smith ” ) should return ” Smith, John ” .
def format_name(first, last):
# TODO: Return the name in ” last, first ” format
pass

Q22. Which components are required in every Python while loop?

 
 
 
 

Q23. Fix the off-by-one error in this function that should return the first 3 characters of a string.
def first_three(text):
return text[0:2]

Q24. Which keyword is used to exit a loop prematurely in Python?

 
 
 
 

Q25. Which keyword moves a loop immediately to its subsequent iteration?

 
 
 
 

Q26. Which Python data structure cannot be modified after creation?

 
 
 
 

Q27. A program needs to update all values in a list by adding 5 to each number. Which for loop structure accomplishes this task?

 
 
 

Q28. A dictionary prices = { ‘ apple ‘ : 1.50, ‘ banana ‘ : 0.75, ‘ orange ‘ : 2.00} needs to have all values increased by
0.25. Which code correctly accomplishes this task?

 
 
 

Q29. A program needs to display only positive, non-zero numbers from a list containing a mixture of integer and decimal values. Which conditional statement should be placed inside the loop?

 
 
 
 

Q30. Complete the function get_max(a, b) that returns the larger of two numbers. If they are equal, return either one.
def get_max(a, b):
# TODO: Return the larger of a and b
pass

Q31. What must a developer do to run Python code written in a text editor?

 
 
 
 

Q32. Which data type does the expression 5 > 3 evaluate to in Python?

 
 
 
 

Q33. Which terminal command is used to navigate to a different directory before running a Python script?

 
 
 
 

Q34. Which tool is used to execute Python code line-by-line interactively within a terminal?

 
 
 
 

Q35. In the code for item in my_list:, what does item represent?

 
 
 
 

Q36. What must be consistent within a Python code block for the code to run without syntax errors?

 
 
 
 

Q37. What happens when theRunbutton is clicked in a Python development environment?

 
 
 
 

Q38. Which Python data structure contains only unique elements and does not support indexing?

 
 
 
 

Q39. Which type of loop repeatedly checks a condition to determine whether to continue?

 
 
 
 

Q40. Write a complete function password_strength(password) that returns ” Strong ” if the password is at least 8 characters long and contains both letters and numbers, ” Weak ” otherwise.
For example, password_strength( ” abc123def ” ) should return ” Strong ” .
def password_strength(password):
# TODO: Return ” Strong ” or ” Weak ” based on password criteria
if len(password) < 8:
return ” Weak “
has_letter = False
has_number = False
for char in password:
if char.isalpha():
has_letter = True
elif char.isdigit():
has_number = True
# TODO: Add your return logic here based on has_letter and has_number
pass

Q41. Modify the function greet_with_default(name) by adding a default value of ” World ” to the name parameter so it can be called with or without an argument.
def greet_with_default(name):
# TODO: Add a default value of ” World ” to the name parameter
return ” Hello ” + name

Q42. Write a complete function reverse_string(text) that takes a string and returns it reversed.
For example, reverse_string( ” hello ” ) should return ” olleh ” .
def reverse_string(text):
# TODO: Return the reversed string
pass

Q43. In the code for item in my_list:, what does item represent?

 
 
 
 

Q44. Complete the function get_dict_keys(data) that takes a dictionary and returns a list of all its keys.
For example, get_dict_keys({ ” name ” : ” John ” , ” age ” : 25}) should return [ ” name ” , ” age ” ].
def get_dict_keys(data):
# TODO: Return a list of all dictionary keys
pass

Q45. Which for loop correctly iterates through a list of student names?

 
 
 
 

New 2026 Foundations-of-Programming-Python Test Tutorial (Updated 62 Questions): https://www.latestcram.com/Foundations-of-Programming-Python-exam-cram-questions.html

Related Links: www.stes.tyc.edu.tw app.intigriti.com www.stes.tyc.edu.tw www.stes.tyc.edu.tw www.stes.tyc.edu.tw www.stes.tyc.edu.tw

leave a comment

Enter the text from the image below