1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zaharov [31]
3 years ago
14

Write a program with a function that accepts a string as an argument and returns the number of uppercase, lowercase, vowel, cons

onants, 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.
Computers and Technology
1 answer:
diamong [38]3 years ago
8 0

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))

You might be interested in
What kind of negative social impact has wireless communications had on today's society?
Zarrin [17]
Kind of negative social impact has had today is debates on social networking and dating and wireless communications are destroying kids from ages 12-16 these 21st century devices are frying are worlds society.
5 0
3 years ago
Read 2 more answers
Translate the following MIPS code to C. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3
Romashka [77]

Answer:

f = 2 * (&A[0])

See explaination for the details.

Explanation:

The registers $s0, $s1, $s2, $s3, and $s4 have values of the variables f, g, h, i, and j respectively. The register $s6 stores the base address of the array A and the register $s7 stores the base address of the array B. The given MIPS code can be converted into the C code as follows:

The first instruction addi $t0, $s6, 4 adding 4 to the base address of the array A and stores it into the register $t0.

Explanation:

If 4 is added to the base address of the array A, then it becomes the address of the second element of the array A i.e., &A[1] and address of A[1] is stored into the register $t0.

C statement:

$t0 = $s6 + 4

$t0 = &A[1]

The second instruction add $t1, $s6, $0 adding the value of the register $0 i.e., 32 0’s to the base address of the array A and stores the result into the register $t1.

Explanation:

Adding 32 0’s into the base address of the array A does not change the base address. The base address of the array i.e., &A[0] is stored into the register $t1.

C statement:

$t1 = $s6 + $0

$t1 = $s6

$t1 = &A[0]

The third instruction sw $t1, 0($t0) stores the value of the register $t1 into the memory address (0 + $t0).

Explanation:

The register $t0 has the address of the second element of the array A (A[1]) and adding 0 to this address will make it to point to the second element of the array i.e., A[1].

C statement:

($t0 + 0) = A[1]

A[1] = $t1

A[1] = &A[0]

The fourth instruction lw $t0, 0($t0) load the value at the address ($t0 + 0) into the register $t0.

Explanation:

The memory address ($t0 + 0) has the value stored at the address of the second element of the array i.e., A[1] and it is loaded into the register $t0.

C statement:

$t0 = ($t0 + 0)

$t0 = A[1]

$t0 = &A[0]

The fifth instruction add $s0, $t1, $t0 adds the value of the registers $t1 and $t0 and stores the result into the register $s0.

Explanation:

The register $s0 has the value of the variable f. The addition of the values stored in the regsters $t0 and $t1 will be assigned to the variable f.

C statement:

$s0 = $t1 + $t0

$s0 = &A[0] + &A[0]

f = 2 * (&A[0])

The final C code corresponding to the MIPS code will be f = 2 * (&A[0]) or f = 2 * A where A is the base address of the array.

3 0
2 years ago
Consider this program segment: int newNum = 0, temp; int num = k; // k is some predefined integer value 0 while (num > 10) {
Doss [256]

Answer:

All of these statements are true.

Explanation:

Since the while loop is reversing the integer number and leaving the highest order digit in the num and stores the reversed number in the newNum variable.

It skips one digit so if the num is in the range of [100,1000] it will result in a number between 10 and 100.

This loop can never go in infinite loop for any initial value of num because the loop will run as many times as the number of digits.

and if the value of the num is <=10 the while loop will never run and the value of newNum will be 0.

6 0
3 years ago
Raymond has to send a number of large documents to his charterer accountant for filing his taxes. Which email etiquette should R
CaHeK987 [17]

Raymond should compress the files, and then at the very least ask what would be the appropriate time to email the attachment. It is important to practice good etiquette when using email. If you are sending an email that has attachments, always make sure to mention it in the body of the email. Raymond should also ZIP or compress his large attachments before sending them. This will make them easier to send.

4 0
3 years ago
Read 2 more answers
11.
Svetllana [295]
11. is battle of the bulge
12. rationing
13. trade embargo act
14. germany won the battle is not true
15. force jews to wear stars sown to their clothing to be caught without was punishable by death
3 0
3 years ago
Other questions:
  • Write a client program that writes a struct with a privateFIFO name (call it FIFO_XXXX, where XXXX is the pid that you got from
    11·1 answer
  • Write a while loop that adds the first 100 numbers (from 1 to 100) together. To do so, use a while loop that continues while the
    12·2 answers
  • Implement function bin2dec that takes a binary number bin_num as a string argument and prints out the corresponding decimal numb
    9·1 answer
  • Need help please. this effect my technology
    15·1 answer
  • PLLZZZZZ HELP I WILL GIVE BRAINLIEST IF ANSWER IS RIGHT
    14·2 answers
  • Which statement is true about encoding in Python?
    7·1 answer
  • Why is computer economics important?​
    10·1 answer
  • Im a beginner programmer. what languages should i learn and how do i get better
    13·1 answer
  • A ____ is an Access feature that makes it easy to enter data.
    7·2 answers
  • Which of the following recommendations should you follow when placing access points to provide wireless access for users within
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!