At Westonci.ca, we make it easy to get the answers you need from a community of informed and experienced contributors. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts. Experience the convenience of finding accurate answers to your questions from knowledgeable experts on our platform.
Sagot :
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))
Thanks for using our service. We aim to provide the most accurate answers for all your queries. Visit us again for more insights. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Get the answers you need at Westonci.ca. Stay informed with our latest expert advice.