215k views
2 votes
Create a function named CountVowels() that takes one parameter name epsilon

(in the function)
Create a variable name countNum and set it to zero

Create a for loop that with a lower bound of zero, upper bound of the length of epsilon, and increment of one
(in the loop)
Get the letter in epsilon at the index equal to the value of the looping variable
store this letter into a variable

if the letter is a vowel (a, e, i, o, u)
add 1 to the countNum variable

return countNum


Create a function named ExtractOdds() that takes one parameter name zeta
(in the function)
Create a variable name result and set it to a blank string

Create a for loop that with a lower bound of zero, upper bound of the length of zeta, and increment of one
(in the loop)
Get the letter in epsilon at the index equal to the value of the looping variable
store this letter into a variable

if the value of the looping variable is odd
update result by adding the letter to the end of result


return result

(Main code)
Have the user input a sentence and store the value in variable named sentence_A
Have the user input a sentence and store the value in variable named sentence_B

Call the method CountVowels() passing in sentence_A as a parameter
Print the value returned from calling CountVowels()

Call the method ExtractOdds() passing in sentence_B as a parameter
Print the value returned from calling ExtractOdds()

1 Answer

2 votes

def CountVowels(epsilon):

countNum = 0

for x in range(len(epsilon)):

letter = epsilon[x]

if letter.lower() in "aeiou":

countNum += 1

return countNum

def ExtractOdds(zeta):

result = ""

for x in range(len(zeta)):

if x % 2 == 1:

result += zeta[x]

return result

sentence_A = input("Enter a sentence: ")

sentence_B = input("Enter a sentence: ")

print(CountVowels(sentence_A))

print(ExtractOdds(sentence_B))

I hope this helps!

User LoganHenderson
by
5.2k points