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
muminat
4 years ago
15

Create the strAnalysis() function that takes 1 string argument and returns a string message. The message will be an analysis of

a test string that is passed as an argument to strAnalysis(). The function should respond with messages such as:
"big number"
"small number"
"all alphabetic"
"multiple character types"
The program will call str_analysis() with a string argument from input collected within a while loop. The while loop will test if the input is empty (an empty string "") and continue to loop and gather input until the user submits at least 1 character (input cannot be empty).
The program then calls the str_analysis() function and prints the return message.
Sample input and output:

enter nothing (twice) then enter a word
enter word or integer:
enter word or integer:
enter word or integer: Hello
"Hello" is all alphabetical characters!

alphabetical word input:
enter word or integer: carbonization
"carbonization" is all alphabetical characters!

numeric inputs:
enter word or integer: 30
30 is a smaller number than expected

enter word or integer: 1024
1024 is a pretty big number
loop until non-empty input is submitted

Once the user gives input with characters use the input in calling the str_analysis() function.

Additional Details:
In the body of the str_analysis() function:

Check if string is digits
if digits: convert to int and check if greater than 99
if greater than 99 print a message about a "big number"
if not greater than 99 print message about "small number"
check if string isalpha then (since not digits)
if isalpha print message about being all alpha
if not isalpha print a message about being neither all alpha nor all digit
call the function with a string from user input

Run and test your code before submitting
# [ ] create, call and test the str_analysis() function
Computers and Technology
1 answer:
nydimaria [60]4 years ago
7 0

Answer:

def str_analysis(s):

   if s.isdigit():

       s = int(s)

       if s > 99:

           message = str(s) + " is a pretty big number"

       else:

           message = str(s) + " is a smaller number than expected"

       

   elif s.isalpha():

       message = s + " is all alphabetical characters!"

   else:

           message = "There are multiple character types"

   

   return message;

   

s = input("enter word or integer: ")

while s != "":

   print(str_analysis(s))

   s = input("enter word or integer: ")

Explanation:

- Check if the string is digit, alphabetical, or mixed inside the function

- Ask the user for the input

- Call and print the result of the <em>str_analysis</em> function inside the while loop

- Keep asking for the input until the given string is empty

You might be interested in
Which of the following is true? A)Checks and Debit Cards both withdraw money directly from a bank account. B)Checks are the most
trapecia [35]
I believe the answer is d
8 0
3 years ago
Read 2 more answers
If you paste a word document text into an excel spreadsheet, the paste optio allow you to keep source formatting or
castortr0y [4]
I think the answer is c
6 0
3 years ago
How do you change your password on this? This isn’t really a “Question” but....
MissTica
You go to edit profile and press the change password button.  click on profile pic
5 0
4 years ago
Read 2 more answers
Host A sends two UDP segments to Server S, one to port 1234 and the other to port 2345. Host B sends one UDP segment to Server S
SOVA2 [1]

Answer:

A

Explanation:

8 0
3 years ago
What command in windows re gives you the opportunity to manage partitions and volumes installed on the system?
KIM [24]
Diskpart command might be the answer
3 0
3 years ago
Other questions:
  • How do i add a blog to my wordpress site?
    7·1 answer
  • The width of a strand of fiber is 19.2 micrometers. if 1500 strands are adhered side by side, how wide would the resulting fabri
    9·1 answer
  • Adding software to a digital device, or adding hardware components to a digital device is called _____ .
    13·1 answer
  • To make sound decisions about information security, management must be informed about the various threats facing the organizatio
    10·1 answer
  • Write a C# program named InchesToCentimeters that declares a named constant that holds the number of centimeters in an inch: 2.5
    14·1 answer
  • From the following list choose all the tasks an operating system performs.
    5·2 answers
  • Burtex Inc. is an application development organization. Twenty five of its knowledgeable employees are retiring in the upcoming
    6·1 answer
  • Convert 311 from decimal to hexadecimal. Show your work.
    9·1 answer
  • Which century saw the development of letterpress printing?
    10·1 answer
  • You want to purchase a computer, and the salesperson refers to separate pricing for a system unit and for the software applicati
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!