Question: # Part ( a ) - Function to count vowels in a word def count _ vowels ( w ) : # Define the vowels
# Part a Function to count vowels in a word
def countvowelsw:
# Define the vowels
vowels 'aeiou'
# Initialize vowel count to
vowelcount
# Loop through each character in the word
for char in w:
# If the character is a vowel, increment the count
if char.lower in vowels:
vowelcount
return vowelcount
# Part b Function to estimate the number of syllables in a word
def countsyllablesw:
# Define the vowels
vowels 'aeiou'
syllablecount
# Check if the first character is a vowel and increment syllable count if so
if lenw and wlower in vowels:
syllablecount
# Loop through the string and check for nonvowel followed by a vowel
for i in range lenw:
if wilower in vowels and wilower not in vowels:
syllablecount
return syllablecount
# Part c Test cases
# Test cases for countvowels function
printcountvowels #
printcountvowelsZ #
printcountvowelssloth #
printcountvowelsSlOTh #
printcountvowelsslothy #
printcountvowelsABACUS #
# Test cases for countsyllables function
printcountsyllables #
printcountsyllablesZ #
printcountsyllablesi #
printcountsyllablesOWL #
printcountsyllablestomato #
printcountsyllableswrite #
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
