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]
3 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]3 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
My duties included reviewing
ycow [4]

Answer:

Please check the explanation.

Explanation:

I carried my logical and administrative skills to stand in implementing the succeeding tasks allocated to me:

  • swotting acquiring trends
  • investigating client data
  • concocting yearly inclination reports.

The bullets and numbering and proper indentation make the reading stuff more easily understandable. And that is what we have done above.

4 0
3 years ago
Adding _____ will allow the user to create text as it will often appear in publications with multiple articles, such as a newspa
mart [117]
Does applications make sense <span />
5 0
3 years ago
Read 2 more answers
Why we need each section of prologprogram?
evablogger [386]

Answer:

Prolog program are used in the artificial intelligence and the web development in a systematic manner process. As, it is also sometimes known as declarative language which basically consist of some facts and list. Prolog program are divided into the sections that are:

  • Domain sections
  • Clauses sections
  • Predicates sections
  • Goal sections

We need each section of the prolog program because all the sections introduced the systematic program and performed there particular functions so by using all these processing steps an efficient function are formed.

6 0
3 years ago
Make a list of any four computer that were used in the history of computer.​
blondinia [14]

Answer:

ENIAC, UNIVAC, EDVAC and IMB 1401 are the list of computers used in history of computer

Explanation:

hope it helps

plz make it brainliest ans

7 0
3 years ago
A small company has a web server in the office that is accessible from the internet. the ip address 192.168.10.15 is assigned to
vaieri [72.5K]
the ip nat inside source command to link the inside local and inside global addresses

I hope this helps! :)
5 0
3 years ago
Other questions:
  • HELP ME PLZZ FFFAAASSSTTTT
    8·2 answers
  • Arpanet was developed by the united states so that there was a communication network that would survive a nuclear war. True or F
    11·1 answer
  • EIPP:________.
    9·2 answers
  • What steps might a company or organization need take in order to keep its digital data secure online?
    8·1 answer
  • Jack wants to save his PowerPoint file electronically. He should store his file in:
    6·2 answers
  • 100 points, PLEASE HELP...To generate numbers between and including -10 to 10 you would use:
    5·1 answer
  • Which type of inventory control is expensive but helps keep inventory especially secure? A. RFID tags B. Barcodes C. Visual merc
    7·1 answer
  • 3. is the system of rules that govern the ordering of values? culture a. Ethics b. organization c. protocol d. value system 3 .
    9·1 answer
  • How do solar ovens track the sun as it moves during the day?
    15·2 answers
  • A __________ attack is a bot attack on a computer system or network that causes a loss of service to users.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!