Docsity

WGU E010 Foundations of Programming (Python) Practice Assessment questions & answers, Exams of Programming Methodologies

Toggle sidebar
bg1
WGU E010 Foundations of Programming
(Python) Practice Assessment questions &
answers 2026/2027 update
Which symbol begins a single-line comment in Python?
// (double forward slash)
# (pound symbol)
* (asterisk)
% (percent symbol) - ✅✅# (pound symbol)
Which data type is the value 3.14 in Python?
Integer
Float
String
Boolean - ✅✅Float
In Python, what must follow the in keyword in a for loop?
A condition
An iterable object
A number
A variable name - ✅✅An iterable object
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download WGU E010 Foundations of Programming (Python) Practice Assessment questions & answers and more Exams Programming Methodologies in PDF only on Docsity!

WGU E010 Foundations of Programming

(Python) Practice Assessment questions &

answers 2026/2027 update

Which symbol begins a single // (double forward slash) -line comment in Python?

(pound symbol) * (asterisk)

% (percent symbol) - ✅✅# (pound symbol) Which data type is the value 3.14 in Python? Integer Float String Boolean - ✅✅Float In Python, what must follow the in keyword in a for loop? A condition An iterable object A number A variable name - ✅✅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 - ✅✅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 - ✅✅A condition and an indented code block Which keyword is used to exit a loop prematurely in Python? return break stop end - ✅✅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 - ✅✅The current element being processed

Access to additional Python libraries Eliminates need to switch between applications Automatic syntax error detection applications - ✅✅Eliminates need to switch between

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 navigate to the script's directory - ✅✅Use the cd command to

Which terminal command is used to navigate to a different directory before running a Python script? move goto cd nav - ✅✅cd Which tool is used to execute Python code line terminal? -by-line interactively within a Python shell Text editor

File explorer Debugger - ✅✅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] - ✅✅filename[-3:] Which index position is returned when the string method .find('python') is applied to the string 'learning python programming'? (^89) 1 2 - ✅✅ 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].

for name in ['Alice', 'Bob', 'Carol']: for name with ['Alice', 'Bob', 'Carol']: for name from ['Alice', 'Bob', 'Carol']: for name = ['Alice', 'Bob', 'Carol'] - ✅✅for name in ['Alice', 'Bob', 'Carol']: Which loop structure processes every individual item in a list called grades? while len(grades) > for grade in grades: 0: for i in range(grades): while grades[0] - ✅✅for grade in grades: A program needs to display only positive, non a mixture of integer and decimal values. -zero numbers from a list containing

Which conditional statement should be placed inside the loop? if number > 0: if number != 0: if number < 0: if number >= 1 - ✅✅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): # TODO: Return double the input number

Example: double_number(5) should return 10

pass return num * 2 - ✅✅def double_number(num):

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 return "Hello " + name - ✅✅def greet_with_default(name="World"):

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 - ✅✅def is_positive(number):

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 if len(password) < 8: - ✅✅def password_strength(password): return "Weak" has_letter = False has_number = False

for char in password: if char.isalpha(): has_letter = True elif char.isdigit(): has_number = True if has_letter and has_number: return "Strong"

else: 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): # TODO: Convert Celsius to Fahrenheit using F = C * 9/5 + 32 pass return celsius * 9 / 5 + 32 - ✅✅def convert_temperature(celsius):

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)] return text[-1] - ✅✅def get_last_character(text):

Fix the missing return statement in this function that should return whether a number is even.

def is_even(number):

You can use either approach: 1️⃣ if a < b: Using a < b:

else:^ return b return a 2️⃣ if a > b: Using a > b:

else:^ return a return b ✅ align so the larger number is returned. Swapping the comparison requires Key point: The if condition and the corresponding return statements must swapping the return values accordingly.