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, 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.
Write a program in python that counts the number of words in President Abraham Lincoln’s Gettysburg...
Write a program in python that counts the number of words in President Abraham Lincoln’s Gettysburg Address from the file provided. Replace all instances of "nation" with country, and all instances of "we" with "Americans". Write the revised address to a new file its for a txt file
Python 3 Write the definition of a function that take one number, that represents a temperature...
Python 3 Write the definition of a function that take one number, that represents a temperature in Fahrenheit and prints the equivalent temperature in degrees Celsius. Write the definition of another function that takes one number, that represents speed in miles/hour and prints the equivalent speed in meters/second. Write the definition of a function named main. It takes no input, hence empty parenthesis, and does the following: - prints Enter 1 to convert Fahrenheit temperature to Celsius - prints on...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT