






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 QUESTIONS |GUARANTEED PASS |LATEST UPDATED VERSION 2026\27WGU E010 FOUNDATIONS OF PROGRAMMING (PYTHON) PRACTICE ASSESSMENT QUESTIONS |GUARANTEED PASS |LATEST UPDATED VERSION 2026\27
Typology: Exams
1 / 12
This page cannot be seen from the preview
Don't miss anything!







Which symbol begins a single-line comment in Python? // (double forward slash)
while loop for loop infinite loop do-while loop -ACCURATE 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 An iterator and a list -ACCURATE ANSWER A condition and an indented code block Which keyword is used to exit a loop prematurely in Python? return break stop end -ACCURATE ANSWER break In the code for item in my_list:, what does item represent? The index of the current element The current element being processed The length of the list The entire list -ACCURATE ANSWER The current element being processed
Eliminates need to switch between applications Automatic syntax error detection -ACCURATE 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 -ACCURATE ANSWER Use the cd command to navigate to the script's directory Which terminal command is used to navigate to a different directory before running a Python script? move goto cd nav -ACCURATE ANSWER cd Which tool is used to execute Python code line-by-line interactively within a terminal? Python shell Text editor File explorer Debugger -ACCURATE ANSWER Python shell
A program processes file names and extracts the last 3 characters representing the file extension. For example, files 'document.pdf' and 'image.png' would return 'pdf' and 'png', respectively. Which slicing approach would work for either of the provided files? filename[:9] filename[9:] filename[-3:] filename[:-3] -ACCURATE ANSWER filename[-3:] Which index position is returned when the string method .find('python') is applied to the string 'learning python programming'? 8 9 1 2 -ACCURATE 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):
pass -ACCURATE ANSWER def add_item(numeric_list, new_number):
for grade in grades: for i in range(grades): while grades[0] -ACCURATE ANSWER for grade in grades: 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? if number > 0: if number != 0: if number < 0: if number >= 1 -ACCURATE ANSWER if number > 0: Complete the function double_number(num) that takes one number parameter and returns double that number. For example, double_number(5) should return 10. def double_number(num):
pass -ACCURATE ANSWER def double_number(num): 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 -ACCURATE ANSWER def greet_with_default(name="World"): 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):
pass -ACCURATE ANSWER def is_positive(number): return number > 0 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_percent):
pass -ACCURATE ANSWER def calculate_discount(price, discount_percent): return price * (1 - discount_percent / 100) 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):
return "Weak" Write a complete function convert_temperature(celsius) that converts Celsius to Fahrenheit using the formula: F = C * 9/5 + 32. For example, convert_temperature(0) should return 32.0. def convert_temperature(celsius):
pass -ACCURATE ANSWER def convert_temperature(celsius): return celsius * 9 / 5 + 32 Fix the indexing error in this function that should return the last character of a string. def get_last_character(text): return text[len(text)] -ACCURATE ANSWER def get_last_character(text): return text[-1] Fix the missing return statement in this function that should return whether a number is even. def is_even(number): if number % 2 == 0: True else: False -ACCURATE ANSWER def is_even(number): if number % 2 == 0:
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 -ACCURATE 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 โฃ Using a < b: if a < b: return b else: return a 2 โฃ Using a > b: if a > b: return a