python Assignment_4
python Assignment_4
Learning Levels: Remembering (L1), Understanding (L2), Application (L3), Analysis (L4), Evaluation (L5),
and Creation (L6)
Write a function reverse_string(s) that takes a string s as input and returns the
reversed string.
Q1. L2, L3
Example: Input: "hello" Output: "olleh"
Write a function count_vowels(s) that takes a string s as input and returns the number
of vowels in the string.
Q2. L2, L3
Example: Input: "hello world" Output: 3
Write a function is_palindrome(s) that takes a string s as input and returns True if the
string is a palindrome, and False otherwise.
Q3. L2, L3
Example: Input: "madam" Output: True
Write a function compress_string(s) that takes a string s as input and returns the
compressed string. The compression should be done by replacing consecutive
Q4. repeated characters with a single character. L4, L6
END