Question

In: Computer Science

This task is solved in Python 3. Develop a function which counts the number of vowels...

This task is solved in Python 3.

Develop a function which counts the number of vowels in a text.

>>> numberofVowels ("There is a cat outside the house")

13

Solutions

Expert Solution

Hello learner,

Thanks for asking.

Here is the required code in python.

def countVowels(sentence):
    count = 0

# convert the each letter of sentence in lower
sentence = sentence.lower()
# use for loop to count the vowel
for i in sentence:
if i in ['a', 'e', 'i', 'o', 'u']:
count += 1
return count

if __name__ == '__main__':
n = str(input("Enter the string to check for vowels: "))
count = countVowels(n)
print(count)

Here is the required code with proper output.

Use proper indentation(space) for less error in the code.

In this code at first sentence is converted into lower digits and then one by one vowel is counted from the string after that number of vowel is printed on the screen.

please upvote and ask if you have any query.


Related Solutions

This task is solved in Python 3. Develop a program that can change the phone number...
This task is solved in Python 3. Develop a program that can change the phone number of a person in phone.txt (hint: the easiest thing is probably to make a new version of the file, and then delete the old one before the new is renamed to phone.txt) Name: John Old phone number: 99776612 New number: 99889999 >>> phone.txt Replaced by ------> phone.txt Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick 99455443 Susan 98122134 Jill...
This task is solved in Python 3. Develop a program that lets the user add new...
This task is solved in Python 3. Develop a program that lets the user add new people to the file phone.txt Add name and number, end with <enter> Name and number: Robin 94567402 Name and number: Jessica 99468283 Name and number: >>> Phone.txt Expanded to ------> Phone.txt Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick 99455443 Susan 98122134 Jill 99655732 Bob 98787896 Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick...
This task is solved in Python 3. Develop a program that can, among other things, manage...
This task is solved in Python 3. Develop a program that can, among other things, manage your courses and course results. It must also be able to calculate the average grade, for all grades or for a selection of grades limited to a certain subject area and / or course level (100, 200 or 300 level). NB! All courses are worth the same amount of credits. The program should have two global collections Courses is a list that contains the...
This task is about classes and objects, and is solved in Python 3. We will look...
This task is about classes and objects, and is solved in Python 3. We will look at two different ways to represent a succession of monarchs, e.g. the series of Norwegian kings from Haakon VII to Harald V, and print it out like this: King Haakon VII of Norway, accession: 1905 King Olav V of Norway, accession: 1957 King Harald V of Norway, accession: 1991 >>> Make a class Monarch with three attributes: the name of the monarch, the nation...
Write a Python function ???????? that takes in a nonnegative semiprime number ? which is the...
Write a Python function ???????? that takes in a nonnegative semiprime number ? which is the product of two prime numbers ? and ? and returns the tuple ( ?, ? ) where ?≤? . Example: ????????(22)=(2,11) Example: ????????(3605282209)=(59447,60647) This problem has a time-out limit of 1 second and a memory limit of 1MB. The number ? in all test-cases will satisfy 4≤?≤800000000000000 For example: Test Result print(factorMe(22)) (2, 11) print(factorMe(3605282209)) (59447, 60647)
Make a python dictionary that counts the number of times each word occurs in the the...
Make a python dictionary that counts the number of times each word occurs in the the book below book_url = 'http://www.gutenberg.org/cache/epub/2680/pg2680.txt'
Make a python dictionary that counts the number of times each word occurs in the the...
Make a python dictionary that counts the number of times each word occurs in the the book below book_url = 'http://www.gutenberg.org/cache/epub/2680/pg2680.txt' without downloading to computer.
Homework 3 Loop and Function (PYTHON) You are asked to develop a compensation calculator application for...
Homework 3 Loop and Function (PYTHON) You are asked to develop a compensation calculator application for a department store. At the department store, the compensation of sales staff consists of a base salary and a commission. The base salary is $5,000, and the commission rate is tiered based on sales amount as following: Sales AmountCommission Rate $0.01 – $5,000 8% $5,000.01 – $10,000 10% $10,000.01 and above12% For example, if the sales amount is $12,000, the commission is calculated as...
IN PYTHON Develop a program in python that includes a number of functions for the multi-server...
IN PYTHON Develop a program in python that includes a number of functions for the multi-server queue. The program accepts arrival and services rates and the number of servers and calls your functions to output the average number of customers and average waiting time in the system.
PYTHON: Describe a recursive algorithm that counts the number of nodes in a singly linked list.
PYTHON: Describe a recursive algorithm that counts the number of nodes in a singly linked list.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT