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
What helps companies and organizations to target masses of people, provide 24/7 services, and deliver better marketing in a chea
Sever21 [200]
The money their making
6 0
3 years ago
Which option is the easiest way to configure macros in Access 2016?
zhuklara [117]
Number 2
Have a nice day
6 0
3 years ago
Differentiate between Scope and Linkage
Lera25 [3.4K]

Answer: The difference between the scope and linkage is as follows:-

  • Scope of the variable is defined as the variable view from different program parts whereas the linkage is described as the link that is made between the variable and the declaration function having the common name.
  • Scope of variable describes about the existing time of the variable in the program whereas linkage is defined for the name of variable present in the program is available at all time .

6 0
3 years ago
Select the best option that should be considered when preparing these images to.be used for the web
DerKrebs [107]
The answer is 1) JPEG  2) TIFF   3) BMP.  
<span>The best option that should be considered when preparing these images to.be used for the web :
</span>1) JPG (jpeg) - Used to compress web images to a small file size without
    sacrificing quality
2) TIFF (tiff) - Used for professional print images to save in a uncompressed 
     file format at high resolution.
3) BMP - Used for either web or print because of the ability to save high
    quality images ether compressed or uncompressed.
6 0
3 years ago
Choose the type of collection created with each assignment statement
Leviafan [203]

Answer:

dictionary

tuple

list

Explanation:

4 0
2 years ago
Other questions:
  • Which of the following is not considered as part of technology literacy?
    8·1 answer
  • Whats a computer scientist.
    5·2 answers
  • Assuming that the message variable contains the string "Happy holidays", the statement message.find("days"); returns a. -1b. 10c
    6·1 answer
  • Which of the following is likely the cause of the bass from a sound system rattling the windows on your car?
    11·1 answer
  • Data means a group of numbers. <br> a. True<br> b. False
    7·1 answer
  • A user on a home network needs to boost the signal of the wireless router. What should the user purchase to accomplish this?
    14·1 answer
  • opearating system protection refers to a mechanism for controling access by programs, processes, or users to both system and use
    7·1 answer
  • What tasks should a laptop accomplish?
    15·1 answer
  • 30 POINTS FOR THE CORRECT ANSWERS
    12·1 answer
  • when an overridden method is called from within a subclass, it will always refer to the version of that method defined by the (a
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!