Docsity

WGU E010 FOUNDATIONS OF PROGRAMMING (PYTHON) PRACTICE ASSESSMENT 2026, Exams of Computer Science

Toggle sidebar
bg1
1 | P a g e
WGU E010 FOUNDATIONS OF
PROGRAMMING (PYTHON) PRACTICE
ASSESSMENT 2026
Which tool is used to execute Python code line-by-line interactively within a
terminal?
Python shell
Text editor
File explorer
Debugger - correct-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:]
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download WGU E010 FOUNDATIONS OF PROGRAMMING (PYTHON) PRACTICE ASSESSMENT 2026 and more Exams Computer Science in PDF only on Docsity!

PROGRAMMING (PYTHON) PRACTICE^ WGU E010 FOUNDATIONS OF

ASSESSMENT 2026

Which tool is used to execute Python code line terminal? -by-line interactively within a Python shell Text editor File explorer Debugger - correct-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[ filename[:--3:]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) 1 2 - 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 # TODO: Add new_number to the end of the list and return the list add_item(numeric_list, new_number):

return grades

Which for loop correctly iterates through a list of student names? for name in [' for name with ['Alice', 'Bob', 'Carol']:Alice', 'Bob', 'Carol']: for name from ['Alice', 'Bob', 'Carol']: for name = ['Alice', 'Bob', 'Carol'] - correct-answer - for name in ['Alice', 'Bob', 'Carol']:

Which loop structure processes every individual item in a list called grades? while len(grades) > 0: for grade in grades: for i in range(grades): while grades[0] - correct-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 - correct-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): # TODO: Return double the input number

TODO: pass - correct Return True if number > 0, False otherwise - 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): # TODO: Calculate and return the final price after discount pass return price * (1 - correct-answer - discount_percent / 100) - def calculate_discount(price, discount_percent):

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

  • (asterisk)

% (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

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 - correct-answer - The current element being processed

Which Python data structure a stored? utomatically prevents duplicate values from being 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 Python code written in a text editor? Save the file and use a Python interpreter. Press a run button within the editor. Upload the code to a web server. Convert the code to machine language first. use a Python interpreter. - correct-answer - Save the file and

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 between applications - correct-answer - Eliminates need to switch

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 if len(passw - correct ord) < 8: - answer - 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"

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 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