question archive 3) We've used wordtool before to loop through nouns and verbs

3) We've used wordtool before to loop through nouns and verbs

Subject:Computer SciencePrice:4.86 Bought7

3) We've used wordtool before to loop through nouns and verbs. For example, let's print the first 10 nouns: words = wordtool . get_nouns ( ) for i in range (10) : print (words [ i ] ) Consider the following: def has_all_vowels (w) : # Write code here to determine whether w has all 5 vowels words = wordtool . get_nouns ( ) position = 0 # Write a while-loop here to stop at the first noun that # has all 5 vowels print( 'Found' , words [position], 'at position', position) # Should print: # Found argumentation at position 456 Thus, in my_has_all_vowels. py your goal here is to write code for the function has_all_vowels() so that it returns True or False, and then write a while loop that tries nouns in sequence until you find the first noun that has all vowels. In your assignment2. pdf, report on the first verb that has all vowels. You will need wordtool.py and words WithPOS.txt.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

CODE :--

 

#please include this line in your code. Since i am using some random nouns for testing i commented this.

#words=wordtool.get_nouns()

def has_all_vowels(w):

#initialize vowels array

vowels=['a','e','i','o','u']

#for each vowel in vowels

for vowel in vowels:

#if any of the vowel is not found in given word w, return False

if vowel not in w:

return False

#if control reaches here, that means all vowels are present in the word. Hence return True

return True

#just using some nouns for testing purpose and code correctness

#Comment this line once you uncomment the actual words=wordtool.get_nouns() line

words=['adventure','dream','success','argumentation']

position=0

#while loop to check the first noun having all the vowels in it. This loop continues till end of the words list.

while position<len(words):

if has_all_vowels(words[position]):

#Call the function has_all_vowels() and check. If True then print it and break the loop

print('Found',words[position],'at position',position)

break

#increment the position by 1

position+=1

OUTPUT :--

Please see the attached file for the complete solution

Related Questions