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
From the set ( 5 , 7 , 9 , 11 , 13 make the inequality w - 4 < 8 true
Ksenya-84 [330]

Answer:

Explanation:

One group of students did an experiment to study the movement of ocean water. The steps of the experiment are listed below.

Fill a rectangular baking glass dish with water.

Place a plastic bag with ice in the water near the left edge of the dish.

Place a lighted lamp near the left edge of the dish so that its light falls directly on the plastic bag.

Put a few drops of ink in the water.

The student did not observe any circulation of ink in the water as expected because the experiment had a flaw. Which of these statements best describes the flaw in the experiment? (2 points)

Not enough ink was added.

Not enough water was taken.

The dish was too small for the experiment.

The lamp and the ice bag were at the same place.

7 0
3 years ago
what is a problem that occurs when someone registers purposely misspelled variations of well-known domain names?
laiz [17]

Answer:

Typosquatting

Explanation:

8 0
3 years ago
C++
Cerrena [4.2K]

Answer:

#include <iostream>

#include<iomanip>

using namespace std;

double DrivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon)

{

  double dollarCost = 0;

  dollarCost = (dollarsPerGallon * drivenMiles) / milesPerGallon;

  return dollarCost;

}

int main()

{

  double miles = 0;

  double dollars = 0;

  cout << "Enter miles per Gallon   : ";

  cin >> miles;

  cout << "Enter dollars per Gallon: ";

  cin >> dollars;

  cout << fixed << setprecision(2);

  cout << endl;

  cout << "Gas cost for 10 miles : " << DrivingCost(10, miles, dollars) << endl;

  cout << "Gas cost for 50 miles : " <<DrivingCost(50, miles, dollars) << endl;

  cout << "Gas cost for 400 miles: "<<DrivingCost(400, miles, dollars) << endl;

  return 0;

}

Explanation:

  • Create a method definition of DrivingCost that accepts  three input double data type parameters drivenMiles,  milesPerGallon, and dollarsPerGallon and returns  the dollar cost to drive those miles .
  • Calculate total dollar cost and store in the variable, dollarCost .
  • Prompt and read the miles and dollars per gallon  as input from the user .
  • Call the DrivingCost function three times  for the output to the gas cost for 10 miles,  50 miles, and 400 miles.

 

4 0
3 years ago
Read 2 more answers
true of false one reason to move to a paperless society is that printers are becoming prohibitively expensive
Yakvenalex [24]
True because printers, which require paper, are becoming more expensive. A paperless society has the advantage of being cheaper in this aspect.
5 0
3 years ago
Some of your non-Windows clients aren't registering their hostnames with the DNS server. You don't require secure updates on the
Ivenika [448]

Answer:

c.Update DNS records dynamically for DHCP clients that don't request updates.

Explanation:

A DNS server is a computer server that contains a database of public IP addresses and their associated host names, and in most cases serves to resolve, or translate, those names to IP addresses as requested.

A DHCP Server is a network server that automatically provides and assigns IP addresses, default gateways and other network parameters to client devices.

Dynamic DNS is a method of automatically updating a name server in the Domain Name Server, often in real time.

5 0
3 years ago
Other questions:
  • Question: A famous Disney Movie partially takes place in this city.
    15·2 answers
  • Distinguish between engineering and architecture​
    5·1 answer
  • Serveral cheetas are growling at each other while hunting for animals.for which need are they competing?
    14·1 answer
  • How is the Internet Simulator similar to the Actual Internet? How is it different?
    7·1 answer
  • Is it safe to take apart a computer monitor?
    13·1 answer
  • Which one of these is correct PI of a XML document?
    13·1 answer
  • Kevin gets a call from a user who is trying to install a new piece of software. The user doesn’t have administrative rights, so
    10·1 answer
  • How does this happen on brianly???
    5·2 answers
  • HELP I WILL GIVVE BRAINLY AND 15 POINTS
    6·1 answer
  • Why are men more exposed to mass media?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!