SIMULATION
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
SIMULATION
Fix the missing function call in this function that should return the uppercase version of a string.
def make_uppercase(text):
return text.upper
SIMULATION
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
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?
SIMULATION
Complete the function get_max(a, b) that returns the larger of two numbers. If they are equal, return either one.
def get_max(a, b):
# TODO: Return the larger of a and b
pass