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
zhannawk [14.2K]
4 years ago
11

2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you

to use a for loop in this function. (2 pts) (3) Extend the program by calling the get_num_of_characters() function and then output the returned result. (1 pt) (4) Extend the program further by implementing the output_without_whitespace() function. output_without_whitespace() outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the output_without_whitespace() function in main(). (2 pts)
Computers and Technology
1 answer:
Lilit [14]4 years ago
6 0

Explanation:

Number of characters: 46

String with no whitespace: Theonlythingwehavetofearisfearitself.

########################################################

def get_num_of_characters(inputStr):

   count = 0

   for i in range(0,len(inputStr)):

       count = count + 1

   #count = len(inputStr)

   return count

def output_without_whitespace(inputStr):

   #statement = statement.strip()

   statement2 = ' '

   for i in range(0,len(inputStr)):

        if(inputStr[i] == ' '):

           statement2 = statement2

       else:

           statement2 = statement2 + inputStr[i]

       

   inputStr = inputStr.replace(" ", "")

   return statement2

inputStr = input('Enter a sentence or phrase: ')

print()

print('You entered:', inputStr)

num = get_num_of_characters(inputStr)

print()

print('Number of characters:', num)

print('String with no whitespace:',output_without_whitespace(inputStr))

#if __name__ == '__main__':

   # Think I'm supposed to use this if statement

########################################################

'''ERROR MESSAGE WHEN RUNNING TEST

Unit test

0/1

Tests that get_num_of_characters() returns 46 for "The only thing we have to fear is fear itself."

Your output

Enter a sentence or phrase: Traceback (most recent call last):

 File "zyLabsUnitTestRunner.py", line 4, in <module>

   from zyLabsUnitTest import test_passed

 File "/home/runner/local/unit_test_student_code/zyLabsUnitTest.py", line 1, in <module>

   from main import get_num_of_characters

 File "/home/runner/local/unit_test_student_code/main.py", line 19, in <module>

   inputStr = input('Enter a sentence or phrase: ')

EOFError: EOF when reading a line'''

You might be interested in
Amy just added a 462 meter run of fiber optic cable to the network what should she do next?
andriy [413]

Answer:

test it.

Explanation:

Based on the information provided within the question it can be said that the next logical step after installing the 462 meter run of cable would be to test it. This is done in order to make sure that there were no malfunctions during installation and that everything is running through the cable correctly. To test the cable you must perform an end-to-end attenuation test which will verify the quality of the installation as well as ensure high quality system performance.

6 0
3 years ago
Software design and implementation are interleaved activities. The level of detail in the design depends on the type of system b
zavuch27 [327]

Answer:

True is the correct answer for the above question.

Explanation:

  • The software design consists of several phases which are also called the life cycle. It is used to develop the software.
  • But there are so many models, that consist of rules and guidelines to states how these phases can work. It states that in which steps of the designing phase, which part of the life cycle works.
  • For example, in the waterfall model, all phases work on a single time and there is no option to follow this in reverse scenario and in the agile model only one module is developed and proved by the client.
  • So the style of the phase can state the model, which is followed in the software development process.
  • This above concept can also be started from the question. Hence True is the correct answer.

5 0
3 years ago
Micro sleep is when you ____.
Levart [38]

Microsleep refers to periods of sleep that last from a few to several seconds.

8 0
3 years ago
Read 2 more answers
From the standpoint of the governing bodies of .com, why is it important that owners of individual domains maintain authoritativ
mixer [17]

Answer:

Explanation:

A subdomain is really important on the internet, we can categorize our blog, e-commerce or simple informative website, for example, if we want to have a blog and e.commerce of the same topic, we can have a subdomain for each website, if we separate our website, and we administrate our content is a good signal for SEO, we could have more promotion in search engine.

4 0
3 years ago
What is the danger in judging someone according to his or her social networking profile
AfilCa [17]
They could find you and throw hands.
8 0
3 years ago
Other questions:
  • What is an (CR) Optical character recognition?
    13·2 answers
  • What country is now the number one source of attack traffic?
    5·1 answer
  • Which of the following is not a method of data management?
    15·1 answer
  • What is a central location that houses Joint Information System (JIS) operations and where public information staff perform publ
    6·1 answer
  • HELP QUICKLY!!! IF YOUR RIGHT I'LL MARK YOU BRAINLIEST
    15·2 answers
  • Dang was accepted to a biology program with a rigorous schedule and a high tuition, but good professors. What would be a benefit
    10·2 answers
  • Visit the quick access toolbar to find help when looking for certain commands. True False
    15·2 answers
  • Outline four types of cyber law.
    14·1 answer
  • If each integer occupies one 64-bit memory cell and is stored using sign/magnitude notation, what are the largest (in terms of a
    12·1 answer
  • Which of the following is not a component of Power BI?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!