Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Python 3.4 Question13A The letters a, e, i, o and u are vowels. No other lett

ID: 3691398 • Letter: I

Question

In Python 3.4

Question13A

The letters a, e, i, o and u are vowels. No other letter is a vowel. Write a function named vowelCount() that takes a string, s, as a parameter and returns the number of vowels that scontains. The string smay contain both upper and lower case characters. For example, the function call vowelCount('Amendment') should return the integer 3 because there are 3 occurrences of the letters 'A' and 'e'.

Question13b

Write a function named manyVowels() that takes a body of text, t, and an integer, i, as parameters. The text tcontains only lower case letters and white space. manyVowels() should return a dictionary in which the keys are all words in tthat contain at least i vowels. The value corresponding to each key is the number of vowels in it. For full credit, manyVowels() must call the helper function vowelCount() from Question 13a to determine the number of vowels in each word.

For example, if the input text contains the word "hello", then "hello" should be a key in the dictionary and its value should be 2 because there are 2 vowels in "hello".

Input:

1. t, a text consisting of lower case letters and white space

2. i, a threshold number of vowels Return:a dictionary of key-value pairs in which the keys are the words in tcontaining at least i vowels and the value of each key is the number of vowels it contains.

For example, the following would be correct output.

text = 'they are endowed by their creator with certain unalienable rights'

print(manyVowels(text, 3))

{'certain': 3, 'unalienable': 6, 'creator': 3, 'endowed': 3}

Explanation / Answer

13A)

def isvowel(ch):
if(ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u'):
return True
if(ch=='A' or ch=='E' or ch=='I' or ch=='O' or ch=='U'):
return True
return False
def vowelCount(s):
count=0
for i in s:
if(isvowel(i)):
count+=1
return count
print(vowelCount('Amendment'))

13B)

def isvowel(ch):
if(ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u'):
return True
if(ch=='A' or ch=='E' or ch=='I' or ch=='O' or ch=='U'):
return True
return False
def vowelCount(s):
count=0
for i in s:
if(isvowel(i)):
count+=1
return count
def manyVowels(t,i):
words = t.split(" ")
ans = {}
for j in words:
if(vowelCount(j)>=i):
ans[j] = vowelCount(j)
return ans
print(manyVowels("they are endowed by their creator with certain unalienable rights",3))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote