Write a program with a function that accepts a string as an argument and returns the number of uppercase, lowercase, vowel, consonants, and punctuation that the string contains. The application should let the user enter a string and should display the number of uppercases, lowercases, vowels, consonants, and punctuations that the string contains.

Answers

Answer 1

Answer:

Explanation:

The following code is written in Python. It is a function called checkString that takes in a string as an argument and loops through each char in that string and checking to see if it is lowercase, uppercase, vowel, consonant, or punctuations. It adds 1 to the correct variable. At the end of the loop it prints out all of the variables. The picture below shows a test output with the string "Brainly, Question."

def checkString(word):

   uppercase = 0

   lowercase = 0

   vowel = 0

   consonants = 0

   punctuation = 0

   vowelArray = ['a', 'e', 'i', 'o','u', 'y' ]

   consonantArray = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']

   punctuationArray = ['.', '!', '?', ',', ';', '(', ')']

   for char in word:

       if char.isupper():

           uppercase += 1

       else:

           lowercase += 1

       if char.lower() in vowelArray:

           vowel += 1

       elif char.lower() in consonantArray:

           consonants += 1

       if char in punctuationArray:

           punctuation += 1

   print('Uppercase: ' + str(uppercase))

   print('Lowercase: ' + str(lowercase))

   print('Vowels: ' + str(vowel))

   print('Consonants: ' + str(consonants))

   print('Punctuations: ' + str(punctuation))


Related Questions

what is SEO and SEM?

Answers

Answer:

SEO stands for “search engine optimization.” In simple terms, it means the process of improving your site to increase its visibility for relevant searches.

SEM, or search engine marketing, is the act of using paid strategies to increase search visibility.

Other Questions
please help me with this! Brainiest and 10 points The step function f(x) is graphed. What is the value of f(0)? -2 -1 0 1 help gggggggggggggggggggggggggggggggggggggg Which of the following separatesvisible white light into the variouscolors of the spectrum?A. a spectrumB. a prismC. an x-ray machineD. an electromagnetic spectrum All of the following statements are true about a member firm's Business Continuity Plan EXCEPT the BCP must: A address how the member firm would deal with a significant business disruption B include scenarios of increasing severity and how the member plans to respond C be provided to any new customer at account opening D be provided to customers every 36 months after the account is opened A pure copper cube has an edge length of 1.76 cm. How many copper atoms does it contain? (volume of a cube = (edge length)^3; density of copper = 8.96 g/cm^3 ) 1. Find P (phone has internet or phone plays music) using this Venn diagram.2. Explain why we need to subtract P(A and B) in the equation P(A or B) = P(A) + P(B) - P(A and B). The midpoint of AB is M(6, 3) . If the coordinates of A are (7, 4) , what are the coordinates of B? The Molding Department of Sunland Company has the following production data: beginning work in process 25200 units (70% complete), started into production 474000 units, completed and transferred out 449700 units, and ending work in process 49500 units (30% complete). Assuming all materials are entered at the beginning of the process, equivalent units of production for materials are:____.a. 459150. b. 499200.c. 464550.d. 449700. When a perfectly competitive firm decides to shut down, Group of answer choices marginal cost is above average variable cost. What is the vertex of the quadratic function below?y = 1/2x^2 + x. + 3A. (-1,5)B. (1/2,3)C. (1,3)D. (-1/,5/2) can anyone give me evidence that supports the way that the American people felt about immigrants during the 3 different time periods. The whatsystem proyides structure to the body and protectsinternal organs. What is the value of x? what is one thing every human being does at the same time SORRY again but can someone pliss help me with?i got the answer wrongno links The Fischer esterification mechanism is examined in this question. The overall reaction is: Benzoic acid, C H 3 O H and H C l react to form a methyl ester, H 2 O and H C l. Benzoic acid is a carboxylic acid bonded to a benzene ring. Identify the results or mechanism of each step. A seller uses a periodic inventory system, and on April 4, it sells $5,000 in merchandise on credit (when its cost is $2,400) to a customer on credit terms of 3/10, n/30. On April 5, the customer returns merchandise for a cash refund of $500.Required:Complete the seller's necessary journal entry. What is filtration??