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
What Are some examples of options you can use for bullets? Check all that apply
murzikaleks [220]
Please show the answer options for this problem as otherwise we will be unable to help you.
7 0
3 years ago
What type of media can be edited and published by anyone?
marissa [1.9K]
Websites.

Websites can be edited and anything can be placed and called information or news.
8 0
3 years ago
Read 2 more answers
Web browsers are used to browse the World Wide Web. <br> True or false
irakobra [83]
It's true. When you use an adress link you can see that it begin with www and that means world wide web
8 0
3 years ago
Read 2 more answers
Analyzing computer systems to gather potential legal evidence is computer ________
hodyreva [135]
It is called computer forensics.
5 0
3 years ago
You are the IT security administrator for a small corporate network. You would like to use Group Policy to enforce settings for
LuckyWell [14K]

Answer/Explanation:

To Complete this lab, do the following:

1. From Server Manager, select Tools > Group Policy Management.

2. Expand Forest: CorpNet.com > Domains > CorpNet.com.

3. Right-click the OU where the policy will be linked and select Create a GPO in this domain, and link it here.

4. In the Name field, enter the GPO name; then click OK.

5. Link the GPO to additional OUs as follows:

a. Right-click the next OU and select Link an Existing GPO to link the GPO to another OU.

b. Under Group Policy objects, select Workstation Settings from the list; then click OK.

c. Repeat step 5 to link additional OUs.

6. Import a security policy template as follows:

a. Expand Group Policy Objects.

b. Right-click Workstation Settings and select Edit.

c. Under Computer Configuration, expand Policies > Windows Settings.

d. Right-click Security Settings and select Import Policy.

e. Browse to the C:\Templates.

f. Select ws_sec.inf; then click Open.

Cheers

3 0
3 years ago
Other questions:
  • What is the definition of an extinct species?
    8·2 answers
  • Using a subject directory, you locate a particular topic by clicking links through different levels. a. True b. False
    10·1 answer
  • 1.    Design a circuit that when the binary input is 0, 1, 2, 3,4,5,6, and 7 the binary output is one greater than the input.  W
    13·1 answer
  • Read the sentence.
    10·1 answer
  • Students who respond promptly to e-mails are following which netiquette rule?
    13·2 answers
  • Where should i go if i want to begin learning how to code a video game. What are your recommendations to a 16 yr old to learn co
    13·1 answer
  • Laura has many online accounts discuss the privacy concerns associated with individuals use of the Internet
    15·1 answer
  • What is a special character when creating a password?
    8·2 answers
  • Which role involves designing and creating advertisements for marketing purposes?
    14·1 answer
  • Your design company needs to create a sample animation for a client very quickly. You already have the basic graphics, and the c
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!