Write a Python function called hasVowels() that takes in a string parameter myst
ID: 3762860 • Letter: W
Question
Write a Python function called hasVowels() that takes in a string parameter mystring. It should then go through mystring and return True if mystring has at least one vowel, and return False otherwise. Write a Python function called factorial() that takes in an integer parameter num. and returns the factorial of num. Write a Python function called ion23() that takes in a string parameter word. If word ends in 'ion', it should replace 'ion' with 'e' and return the new word. Otherwise, it just returns the original word. (Textbook problem 3.42. Page 92) Write a Python function called partition() that takes in a list of strings called players, as parameter, and returns a new list consisting of only those strings from the original which begin with a letter from A to M (Inclusive), (Textbook Problem 3.3B. Pago 92) Write a Python function called distance() that takes in an int parameter called time which is the time elapsed In seconds between the flash and the sound of thunder. The function should return the distance from lighting strike In kilometers. The speed of sound can be assumed to be 340.29 meters and there are 1000 meters in a kilometer. (textbook problem 3.43, Page 93)Explanation / Answer
1.
def hasVowels(string):
if len(set(string) & set('aeiou')):
return True
else:
return False
output:
hasVowels('test')
True
2).
def factorial(n):
if n==0:
return 1
else:
return n*factorial(n-1)
output:
factorial(5)
120
3)
def ion2e(string):
if string.endswith('ion'):
return string[:len(string)-3]+'e'
else:
return string
output:
ion2e('testion')
teste
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.