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
Once the data center routes to the destination server that hosts the website, whats the next step in the internet process?
Pavlova-9 [17]

User’s browser renders HTML code from destination server into web page

4 0
3 years ago
You just recently opened a business that will be selling items on the Internet. You don’ t actually have a physical store that p
Ivanshal [37]

Answer:

Explanation:

Shipping fee is based on the weight of the item purchased

Name of the store- MIMI Electronics

Items sold- Consumer electronics, mobiles phones, laptops, wearable devices, accessories, digital watches etc

Shipping charges-

Weight Shipping fee

0-1 kg $      5.00

1-2 kg $   10.00

2-4 kg $   15.00

4-7 kg $   20.00

7-10 kg $   30.00

10 kg + $   50.00

Shipping fee function

F(x)= 5 for all x [0,1]

F(x)= 10 for all x (1,2]

F(x)= 15 for all x (2,4]

F(x)= 20 for all x (4,7]

F(x)= 30 for all x (7,10]

F(x)= 50 for all x (10,infinity)

shipping charge function is a step function where the steps are mentioned in terms of weight.

Shipping charge could also be determined using a piece wise function where the shipping fee is fixed for each piece and is charged based on number of pieces ordered instead of weight of the order

5 0
3 years ago
Este tipo de software sirve para controlar e interactuar con el sistema operativo, proporcionando control sobre el hardware y da
attashe74 [19]

Answer: c

Explanation:

4 0
3 years ago
When studying an information system, illustrations of actual documents should be collected using a process called _____.
Oliga [24]
<span>When studying an information system, illustrations of actual documents should be collected using a process called sampling. Correct answer: D
</span>This process systematically selects representative elements of a population with the goal to get representative and useful information about the population as a whole and it is useful when <span>data sets that are too large to efficiently analyze in full.</span>
6 0
3 years ago
________ are hardware devices or software programs that direct messages as they travel between networks.
In-s [12.5K]
<span>Routers are hardware devices or software programs that direct messages as they travel between networks. the answer is routers</span>
5 0
3 years ago
Other questions:
  • Consider the following method.
    13·1 answer
  • What does CPC stand for?
    6·2 answers
  • Two or more computers that are linked together are called which of the following
    10·1 answer
  • Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of integer
    14·2 answers
  • You are evaluating the bounce rate of your overall website traffic and find that users with a social media referral source have
    9·1 answer
  • What is abbreviation of the computer​
    15·2 answers
  • Question 1
    8·1 answer
  • Which of the following statements about interpreting colors are true? Select 3 options.
    11·1 answer
  • Class.object.method is an example of using the ______<br> to access the elements of a class.
    9·1 answer
  • Which instruction is used to convert an integer value to float and push it onto the fpu stack?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!