WGU Foundations-of-Programming-Python Practice Exam Questions & Answers
WGU Foundations-of-Programming-Python Exam Details
Key details for this exam, checked against the published exam outline
- Exam Code
- Foundations-of-Programming-Python
- Full Name
- Foundations of Programming (Python) - E010 JIV1
- Issuing Body
- WGU Courses and Certifications
- Question Format (Our Bank)
- Multiple Choice
- Full Question Set
- 60 questions Get All Questions
Free Foundations-of-Programming-Python Practice Questions
Each question shows the correct answer and an explanation of why it is right
Question 1 Domain 5 Data Structures and Input/Output
Which terminal command is used to navigate to a different directory before running a Python script?
The command cd means ''change directory.'' It is used in a terminal to move from one folder to another.
Example:
cd Desktop
After navigating to the correct folder, a Python script can be run with a command such as:
python script.py
Therefore, the correct answer isC. cd.
Question 2 Domain 3 Loops and Iteration
Which punctuation mark must appear at the end of an if statement line?
In Python, an if statement line must end with a colon.
Example:
age = 18
if age >= 18:
print('Adult')
The colon : tells Python that an indented block of code follows. That indented block contains the statements that should run when the condition is true.
A semicolon, period, or comma is not used to begin the body of an if statement in Python.
Therefore, the correct answer is B. : colon.
Question 3 Domain 3 Loops and Iteration
Which index position is returned when the string method .find('python') is applied to the string 'learning python programming'?
The .find() method returns the lowest index where the searched substring is found.
Example:
'learning python programming'.find('python')
Output:
9
Indexing starts at 0 in Python. In the string 'learning python programming', the word 'python' begins at index 9. Python's built-in types documentation describes str.find() as returning the lowest index where the substring is found.
Therefore, the correct answer isB. 9.
Get the complete Foundations-of-Programming-Python question set
$20$40
Question 4 Domain 4 Functions and Modular Programming
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}.
A dictionary stores data as key-value pairs. In this function, the student name is the key, and the grade is the value.
Correct code:
def update_grade(grades, student, new_grade):
grades[student] = new_grade
return grades
Example:
update_grade({'Alice': 85, 'Bob': 90}, 'Alice', 95)
Result:
{'Alice': 95, 'Bob': 90}
Python's built-in types documentation includes dictionaries as mapping types, where values are accessed and updated using keys.
Therefore, the correct answer isA.
Question 5 Domain 5 Data Structures and Input/Output
SIMULATION
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
Step 1: A default parameter value allows a function to be called even when no argument is provided.
Step 2: The default value should be added in the function header.
Step 3: The parameter name should have the default value 'World'.
Correct code:
def greet_with_default(name='World'):
return 'Hello ' + name
Example:
print(greet_with_default())
print(greet_with_default('Alice'))
Output:
Hello World
Hello Alice
Question 6 Domain 4 Functions and Modular Programming
SIMULATION
Write a complete function calculate_average(grades) that takes a list of grades and returns the average as a float.
For example, calculate_average([85, 92, 78]) should return 85.0.
def calculate_average(grades):
# TODO: Calculate and return the average grade as a float
pass
Step 1: The function receives one parameter named grades, which is a list of numbers.
Step 2: Use sum(grades) to add all the grades together.
Step 3: Use len(grades) to count how many grades are in the list.
Step 4: Divide the total by the number of grades.
Correct code:
def calculate_average(grades):
return sum(grades) / len(grades)
Example:
print(calculate_average([85, 92, 78]))
Output:
85.0
Question 7 Domain 5 Data Structures and Input/Output
Which keyword is used to exit a loop prematurely in Python?
The break keyword exits a loop immediately before the loop condition naturally becomes false or before all items have been processed.
Example:
for number in range(10):
if number == 5:
break
print(number)
When number becomes 5, the loop stops. Python's control-flow documentation explains the use of break in loops.
Therefore, the correct answer isB. break.
What the WGU Foundations-of-Programming-Python Exam Covers
5 domains from the WGU Foundations-of-Programming-Python exam outline, with approximate weightings. Every sample question above is tagged with the domain it comes from
Domain 1 Variables, Data Types, and Basic Operations
Declare and initialize variables, assign values, and perform arithmetic and string operations. Recognize data type behavior including integers, floats, strings, and booleans, and apply type conversion where needed.
Domain 2 Control Flow and Decision Making
Use if, elif, and else statements to direct program flow based on conditions. Apply logical operators (and, or, not) and write conditional expressions to handle different scenarios.
Domain 3 Loops and Iteration
Use for and while loops to repeat code blocks and iterate through sequences like lists and strings. Control loop behavior with break and continue statements.
Domain 4 Functions and Modular Programming
Define and call functions with parameters and return values. Understand variable scope and how to write reusable code modules that follow the DRY principle.
Foundations-of-Programming-Python Exam FAQ
Common questions about the exam itself
What programming experience do I need before taking Foundations of Programming (Python) E010 JIV1?
How long should I study for the Foundations of Programming Python E010 JIV1 exam?
What topics do most candidates find hardest on the E010 JIV1 exam?
Is the Foundations of Programming Python E010 JIV1 exam proctored, and can I take it online?
What score do I need to pass Foundations of Programming (Python) E010 JIV1?
Can I retake the Foundations of Programming Python E010 JIV1 exam if I don't pass?
How long is the Foundations of Programming (Python) E010 JIV1 certification valid after I pass?
What job roles does the Foundations of Programming Python E010 JIV1 certification support?
How does E010 JIV1 relate to other programming certifications in the WGU track?
What format are the questions on the Foundations of Programming Python E010 JIV1 exam?
Other WGU Exams
Free practice questions for more WGU certification exams
