










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
WGU E010 FOUNDATIONS OF PROGRAMMING (PYTHON) PRACTICE ASSESSMENT| ACTUAL QUESTIONS WITH VERIFIED SOLUTIONS 2026
Typology: Exams
1 / 18
This page cannot be seen from the preview
Don't miss anything!











Which symbol begins a single // (double forward slash) -line comment in Python?
% (percent symbol) - correct-answer - # (pound symbol)
Which data type is the value 3.14 in Python? Integer Float String Boolean - correct-answer - Float
In Python, what must follow the in keyword in a for loop? A condition An iterable object A number A variable name - correct-answer - An iterable object
Which type of loop is designed for iterating a specific number of times? while loop for loop infinite loop do-while loop - correct-answer - for loop
Which components are required in every Python while loop? A condition and an indented code block A variable and a return statement A counter and a break statement
List Tuple Dictionary Set - correct-answer - Set
Which Python data structure cannot be modified after creation? List Dictionary Tuple Set - correct-answer - Tuple
What must a developer do to run P Save the file and use a Python interpreter.ython code written in a text editor? Press a run button within the editor. Upload the code to a web server. Convert the code to machine language first. - correct-answer - Save the file and use a Python interpreter.
What advantage does an integrated terminal provide compared to using a separate terminal application? Faster code execution speed Access to additional Python libraries Eliminates need to switch between applications Automatic syntax error detection - correct-answer - Eliminates need to switch between applications
Which action allows a Python script located in a different folder to be executed in the terminal? Use the edit command to open the script first Move the script to your desktop Use the cd command to navigate to the script's directory Rename the script to match the terminal's path command to navigate to the script's directory - correct-answer - Use the cd
return num * 2
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):
return "Hello " + name
Complete the function is_positive(number) that returns True if the number is greater than 0, and False otherwise.
def is_positive(number): # TODO: Return True if number > 0, False otherwise
pass return number > 0 - correct-answer - def is_positive(number):
Write a complete function calculate_discount(price, discount_percent) that calculates and returns the final price after applying a discount percentage.
For example, calculate_discount(75, 20) should return 60.0. def calculate_discount(price, discount_per # TODO: Calculate and return the final price after discountcent): pass return price * (1 - correct-answer - discount_percent / 100) - def calculate_discount(price, discount_percent):
Which terminal command is used to navigate to a different directory before running a Python script? move goto
filename[:-3] - correct-answer - filename[-3:]
Which index position is returned when the string method .find('python') is applied to the string 'learning python programming'? (^89) (^12) - correct-answer - 9
Complete the function add_item(numeric_list, new_number) that takes a list of numbers and a new number, and returns a new list that appends the new number to the end of the list. For example, add_item([1, 2, 3], 4) should return [1, 2, 3, 4].
def add_item(numeric_list, new_number): # TODO: Add new_number to the end of the list and return the list
pass numeric_list.append(new_number) - correct-answer - def add_item(numeric_list, new_number): return numeric_list
Complete the function update_grade(grades, student, new_grade) that takes a grades dictionary, a student name, and a new grade, then updates that student's grade and returns the dictionary. For example, update_grade({"Alice": 85, "Bob": 90}, "Alice", 95) should return {"Alice": 95, "Bob": 90}.
def update_grade(grades, student, new_grade): # TODO: Update the student's grade and return the dictionary
pass grades[student] = new_grade - correct-answer - def update_grade(grades, student, new_grade): return grades
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
pass if len(password) < 8: - correct-answer - def password_strength(password): return "Weak" has_letter = False has_number = False
for char in password: if char.isalpha(): has elif char.isdigit():_letter = True has_number = True if has_letter and has_number: return "Strong" else: return "Weak"
Fix the missing return statement in this fu number is even. nction that should return whether a
def is_even(number): if number % 2 == 0: True else: False if number % 2 == 0: - correct-answer - def is_even(number): return True else: return False
Fix the logic error in this function that should return the larger of two numbers. def find_maximum(a, b):
if a < b: return a else: return b - correct-answer - def find_maximum(a, b): if a < b: return b else: return a
Tip: Correctly returning the larger of two numbers using if-else You can use either approach: 1️ if a < b: ⃣ Using a < b:
else:^ return b return a