Free WGU Foundations-of-Programming-Python Practice Test & Real Exam Questions

  • Exam Code/Number: Foundations-of-Programming-Python
  • Exam Name/Title: Foundations of Programming (Python) - E010 JIV1
  • Certification Provider: WGU
  • Corresponding Certification: Courses and Certificates
  • Exam Questions: 62
  • Updated On: May 31, 2026
What happens when theRunbutton is clicked in a Python development environment?
Correct Answer: D Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
In the code for item in my_list:, what does item represent?
Correct Answer: A Vote an answer
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
Correct Answer:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: First, check the password length using len(password).
Step 2: If the password has fewer than 8 characters, return " Weak " immediately.
Step 3: Create two Boolean variables: has_letter and has_number.
Step 4: Loop through each character in the password.
Step 5: Use .isalpha() to check for letters and .isdigit() to check for numbers.
Step 6: If the password contains both at least one letter and at least one number, return " Strong " .
Step 7: Otherwise, return " Weak " .
Correct code:
def password_strength(password):
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
if has_letter and has_number:
return " Strong "
else:
return " Weak "
Example:
print(password_strength( " abc123def " ))
print(password_strength( " abcdefgh " ))
print(password_strength( " 12345678 " ))
Output:
Strong
Weak
Weak
Complete the function get_dict_keys(data) that takes a dictionary and returns a list of all its keys.
For example, get_dict_keys({ " name " : " John " , " age " : 25}) should return [ " name " , " age " ].
def get_dict_keys(data):
# TODO: Return a list of all dictionary keys
pass
Correct Answer:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: A dictionary stores data as key-value pairs.
Step 2: The .keys() method returns the dictionary's keys.
Step 3: To return the keys as a list, use list(data.keys()).
Correct code:
def get_dict_keys(data):
return list(data.keys())
Example:
print(get_dict_keys({ " name " : " John " , " age " : 25}))
Output:
[ ' name ' , ' age ' ]
In Python, what must follow the in keyword in a for loop?
Correct Answer: D Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Which data type does the expression 5 > 3 evaluate to in Python?
Correct Answer: D Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Write a complete function word_count(text) that counts and returns the number of words in the given text.
Words are separated by spaces.
For example, word_count( " Hello world Python " ) should return 3.
def word_count(text):
# TODO: Count and return the number of words in text
pass
Correct Answer:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: The function receives one string parameter named text.
Step 2: Since words are separated by spaces, use the .split() method to split the string into a list of words.
Step 3: Use len() to count how many items are in the list.
Step 4: Return that count.
Correct code:
def word_count(text):
return len(text.split())
Example:
print(word_count( " Hello world Python " ))
Output:
3