WGU Foundations-of-Programming-Python - Foundations of Programming (Python) - E010 JIV1
Total 60 questions
Which Python data structure contains only unique elements and does not support indexing?
How does Jupyter Notebook function as a development environment?
Which keyword is used to exit a loop prematurely in Python?
What advantage does an integrated terminal provide compared to using a separate terminal application?
A program uses this while loop to count down:
count = 5
while count > 0:
print(count)
Which issue is preventing the loop from working correctly?
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
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
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
Which Python data structure cannot be modified after creation?
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
