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
Ghella [55]
3 years ago
14

: Write a function "def countWords(string)" that returns a count of all words in an input string represented by the variable 'st

ring'.
Computers and Technology
1 answer:
Zina [86]3 years ago
3 0
We can define a word as a group of characters without a space between them. To find the words of the input string , w can use split(delimiter) which returns a list of strings which had the defined delimiter between them in the input string.

def countWords(string):
words = string.split(" ")
count = len(words)
return count

Here we set the delimiter as the space character, and returned the length of the words list. I split each step into its own line for readability, however the function could be one line:

return len(string.split())

Here, no delimiter is specified. If one isn't given, it will default to split at any whitespace, including space.

You might be interested in
a third important logical element is the inverter. an inverter does pretty much what it says. if the input is 0, the output is 1
Mrrafil [7]

Answer:

xy225.252 <  \geqslant  > . \times 5 \times . =  {?}^{2}

7 0
3 years ago
An IT security threat is anything that might cause serious harm to a computer system.
Blababa [14]

Answer:

True

Explanation:

this is true because a threat can endanger the computer and its system

5 0
2 years ago
Why would it be unusual to find a fossil of an organism’s eye?
Slav-nsk [51]
<span>The preservation of anything other than mineral skeletons is (with a few exceptions described below) an extremely rare event. Anything that can decay is likely to be lost. Fur, skin, internal organs – all are immensely vulnerable to the destruction by bacteria, fungi and scavengers that assure their recycling back into the ecosystem. </span>
8 0
2 years ago
Jake was working on an essay for his English class on a stormy Sunday afternoon. Before he could save his document, a big strike
matrenka [14]

Maybe in atosave, Computers mostly save what your working on :3

8 0
3 years ago
Programming CRe-type the code and fix any errors. The code should convert non-positive numbers to 1.
LUCKY_DIMON [66]

Answer:

Given

The above lines of code

Required

Rearrange.

The code is re-arrange d as follows;.

#include<iostream>

int main()

{

int userNum;

scanf("%d", &userNum);

if (userNum > 0)

{

printf("Positive.\n");

}

else

{

printf("Non-positive, converting to 1.\n");

userNum = 1;

printf("Final: %d\n", userNum);

}

return 0;

}

When rearranging lines of codes. one has to be mindful of the programming language, the syntax of the language and control structures in the code;

One should take note of the variable declarations and usage

See attachment for .cpp file

Download cpp
5 0
3 years ago
Other questions:
  • Which of the following is a narrative essay most like
    8·2 answers
  • Ben assembled parts of a computer and created a fully functional desktop PC. He wants the computer to connect to the Internet. W
    10·1 answer
  • What is the code for loading image in matlab
    15·1 answer
  • Microsoft ________ is a cloud storage and file sharing service
    12·1 answer
  • Which social media post indicates your home may be unattended?
    10·1 answer
  • In a case where electrical current leakage from the circuit occurs, the GFCI would do the following:
    10·1 answer
  • For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The v
    13·1 answer
  • When clients connect to a web server using the _________ method, the server logs them on using the iusr account, by default?
    14·1 answer
  • Tech A says that gasoline vapors are lighter than air, so inspection pits do not have a fire hazard like above ground hoists. Te
    9·1 answer
  • Discovery of a vulnerability in a software program can potentially be sold to the government. Group of answer choices True False
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!