Answers Practice Questions with Solutions Newest | Already
Graded A+ Latest Update
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
1|Page
, pass - CORRECT ANSWER ✔✔- 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"
Write a complete function convert_temperature(celsius) that converts Celsius to
Fahrenheit using the formula: F = C * 9/5 + 32.
For example, convert_temperature(0) should return 32.0.
def convert_temperature(celsius):
# TODO: Convert Celsius to Fahrenheit using F = C * 9/5 + 32
2|Page