QuestionDecember 17, 2025

Extra credit: a. Write a Python function called count lowercase()that takes a string as an argument and counts and returns the number of lowercase characters in the argument. b.Write a Python function called count digit() that takes a string as an argument and counts and returns the number of digits in the argument. c. Use the functions in part a. and part b. above to write a Python statement that can be used to validate a password where the password should have at least one lowercase character and one digit.

Extra credit: a. Write a Python function called count lowercase()that takes a string as an argument and counts and returns the number of lowercase characters in the argument. b.Write a Python function called count digit() that takes a string as an argument and counts and returns the number of digits in the argument. c. Use the functions in part a. and part b. above to write a Python statement that can be used to validate a password where the password should have at least one lowercase character and one digit.
Extra credit:
a. Write a Python function called count lowercase()that takes a string as an
argument and counts and returns the number of lowercase characters in the
argument.
b.Write a Python function called count digit() that takes a string as an argument
and counts and returns the number of digits in the argument.
c.
Use the functions in part a. and part b. above to write a Python statement that
can be used to validate a password where the password should have at least
one lowercase character and one digit.

Solution
4.0(166 votes)

Answer

```python def count_lowercase(s): return sum(1 for c in s if c.islower()) def count_digit(s): return sum(1 for c in s if c.isdigit()) password = "abc123" is_valid = count_lowercase(password) >= 1 and count_digit(password) >= 1 print(is_valid) # Output: True ``` Explanation 1. Define count_lowercase() function Use a generator expression to sum characters where c.islower() is True. 2. Define count_digit() function Use a generator expression to sum characters where c.isdigit() is True. 3. Validate password using both functions Check if both counts are at least 1; use logical and.

Explanation

1. Define count_lowercase() function<br /> Use a generator expression to sum characters where $c.islower()$ is True.<br />2. Define count_digit() function<br /> Use a generator expression to sum characters where $c.isdigit()$ is True.<br />3. Validate password using both functions<br /> Check if both counts are at least 1; use logical and.
Click to rate:

Similar Questions