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
3 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]3 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
Need help with these
kolbaska11 [484]
The first one is d the second one is true the third one is false
3 0
3 years ago
Select the correct navigational path to set the name for a cell range.
S_A_V [24]

Answer: formula tab, defined names, name manager

Explanation:

ed 2020

6 0
3 years ago
Read 2 more answers
the_____ tool is used to change the select text to capital letters or small letters (change case /grow font)​
solong [7]

Answer:

on word you can use shortcut "Shift+f3" to change uppercase lowercase and title case if that is what you are asking for

3 0
3 years ago
What are Operating Systems?
horrorfan [7]

Answer:

the software that supports a computer's basic functions, such as scheduling tasks, executing applications, and controlling peripherals.

5 0
2 years ago
Think about the pseudocode that you developed for your adventure game in this unit. Would it have been easier to create a flowch
katovenus [111]

Answer:

it may not be easy

Explanation:

because am using a phone not a cuputer

5 0
2 years ago
Other questions:
  • You work in a customer call center. Martin is on the phone asking about the difference between solid-state drives (SSDs), hybrid
    6·1 answer
  • Search engines enable you to
    14·1 answer
  • 1. Grouping Data in a Pivot Table can help you do what?
    5·1 answer
  • Values that are sent into a function are called _________.<br><br> Program Output
    7·1 answer
  • Jeff has created a table to calculate the cost of raw materials that he purchases monthly. Cell A2 shows the fixed cost of the r
    8·2 answers
  • What will empty the log of Internet sites you have recently viewed
    12·2 answers
  • How does the Problem-solving Process help us to solve everyday Problems?
    13·1 answer
  • Which one is exit controllefd loop ?<br>1.while loop <br>2. for loop<br>3. do loop<br>4. none <br>​
    11·1 answer
  • Write a program (main method) that advises the user on programming language. So if a user for instance enters "Java" the program
    6·1 answer
  • How does the quantity of data affect the accuracy of an experiment?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!