Question

Python program. Character-Analysis Program Problem Statement: Design a program - IN PYTHON - that asks the...

Python program. Character-Analysis Program Problem Statement: Design a program - IN PYTHON - that asks the user to enter a string. The string will then be displayed back to the user. This is followed by determining the number of alphabetic characters, numeric characters, lower_case letters, upper_case letters, whitespace characters, and then displaying them. The user should be given additional chances to enter additional strings, and each time a string is entered, the above process is to be performed. The inputting is to stop when the user enters "end" as the input string. At that point, the total number of alphabetic characters, numeric characters, lower_case letters, upper_case letters, whitespace characters are to be displayed and the program terminated. An algorithm: 1. Prompt the user to enter a string at the keyboard 2. As long as the string is not "end" 2.1 Display the string, along with an appropriate message 2.2 Examine the current character of the string 2.2.1 If it's alphabetic, update the alphabetic_counter and the total_alphabetic_counter 2.2.2 If it's numeric, update the numeric _counter and the total_numeric_counter 2.2.3 If it's a lower_case letter, update the lower_case _counter and the total_lower_case_counter 2.2.4 If it's a upper_case letter, update the upper_case _counter and the total_upper_case_counter 2.2.5 If it's a whitespace character, update the whitespace _counter and the total_whitespace_counter 2.2.6 Continue from step 2.2 with the next character until done with this string 2.3 Display the alphabetic_counter, numeric _counter, lower_case _counter, upper_case _counter, and whitespace _counter, each on a separate line, and each along with an appropriate message 2.4 Prompt the user to enter another string at the keyboard 3. Display the total_alphabetic_counter, total_ numeric _counter, total_lower_case _counter, total_ upper_case _counter, and total_ whitespace _counter, each on a separate line, and each along with an appropriate message 4. Stop ================================================================================== NOTE 1: The program will process alphabetic, numeric, and whitespace characters only.

1 0
Add a comment Improve this question Transcribed image text
Answer #1

Python Programm :

def String_check(string):

    alphabets, numeric, lower, upper,space =[],[],[],[],[]

    for letter in string:

        if letter.isupper():

            upper.append(letter)

        elif letter.islower():

            lower.append(letter)

        elif letter.isspace():

            space.append(letter)

    for letter in string:

        if letter.isalpha():

            alphabets.append(letter)

        elif letter.isdigit():

            numeric.append(letter)

    print('Number of alphabetic characters: {}\nAlphabetic characters :{}'.format(len(alphabets),alphabets))

    print('Number of numeric characters : {} \nNumeric characters: {}'.format(len(numeric),numeric))

    print('Number of lower_case letters : {} \nlower_case letters: {}'.format(len(lower),lower))

    print('Number of upper_case letters :{} \nupper_case letters: {}'.format(len(upper),upper))

    print('Number of whitespace characters : {}\nwhitespace characters: {}'.format(len(space),space))

s = input('Please Enter the String: \n')

print('Given sting is :\n {}'.format(s))

String_check(s)

new_s = input('Please provide addition string or "End":')

if new_s != "End" :

    new_s =new_s + s

    print('New string with previous:{}'.format(new_s))

    String_check(new_s)

else:

    print('End')  

2 4 6 9 check_string > main.py > ... 1 def String_check(string): alphabets, numeric, lower, upper, space =[],[],[],[],[] 3 foPlease Enter the String: Hi i wish you are doing well in covid 19 pandemic time Given sting is : Hi i wish you are doing well

> Good Job! It work

gilbertelea Fri, Nov 26, 2021 12:15 PM

Add a comment
Know the answer?
Add Answer to:
Python program. Character-Analysis Program Problem Statement: Design a program - IN PYTHON - that asks the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in C++, Design a program that asks the user to enter a password, and then analyze...

    in C++, Design a program that asks the user to enter a password, and then analyze the password, and then analyze the password for the following weaknesses: 1. Fewer than 8 characters 2. Does not contain at least one uppercase letter and one lowercase latter 3. Does not contain at least one numeric digit 4. Does not contain at least one special character( a character that is not a letter or numeric digit) 5. Is a sequence of consecutive uppercase...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • Write a program(Python language for the following three questions), with comments, to do the following:   ...

    Write a program(Python language for the following three questions), with comments, to do the following:    Ask the user to enter an alphabetic string and assign the input to a variable str1. Print str1. Check if str1 is valid, i.e. consists of only alphabetic characters. If str1 is valid Print “<str1> is a valid string.” If the first character of str1 is uppercase, print the entire string in uppercase, with a suitable message. If the first character of str1 is...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • 14.3: More Sentences Write a program that allows a user to enter a sentence and then...

    14.3: More Sentences Write a program that allows a user to enter a sentence and then the position of two characters in the sentence. The program should then report whether the two characters are identical or different. When the two characters are identical, the program should display the message: <char> and <char> are identical! Note that <char> should be replaced with the characters from the String. See example output below for more information. When the two characters are different, the...

  • Write a functionthat calculates the first character in a string that exists more than twice in...

    Write a functionthat calculates the first character in a string that exists more than twice in the stringand returns the index of that character or -1 if none exists.The program should prompt the user to enter an entire line including any whitespace as a string. The program then prints out the index and character that exists at least three times or a message “Not found” if all characters of the string have none or single duplicates. In C++ please For...

  • Python Ask the user to enter a character and find out if the character is numeric...

    Python Ask the user to enter a character and find out if the character is numeric (a digit from 0-9), an uppercase letter, a lowercase letter, or none of these. Remember that all characters are defined by ASCII codes, and you do not need to convert the input to int or float. You can just compare it with other values. For example, if the entered character is between 'a an d 'z, the character is a lowercase letter.

  • Write a program that asks the user to enter a string and then asks the user...

    Write a program that asks the user to enter a string and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. python programming

  • Python program Use the provided shift function to create a caesar cipher program. Your program s...

    python program Use the provided shift function to create a caesar cipher program. Your program should have a menu to offer the following options: Read a file as current message Save current message Type in a new message Display current message "Encrypt" message Change the shift value For more details, see the comments in the provided code. NO GLOBAL VARIABLES! Complete the program found in assignment.py. You may not change any provided code. You may only complete the sections labeled:#YOUR...

  • Please write code using Python. Rubric Assignment Solution Total: 100 pts Program successfully retrieves and validates...

    Please write code using Python. Rubric Assignment Solution Total: 100 pts Program successfully retrieves and validates user input 15 pts Morse Code Function Created 10 pts Function Uses Parameters to get input message 15 pts Function successfully converts passed message to Morse Code and returns the Morse Code equivalent of message 45 pts Program calls Morse Code function and outputs the result of the function (i.e. the actual Morse Code) 15 pts Main Function Requirement Part 2 MUST have a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT