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
GREYUIT [131]
3 years ago
6

Write a function called word_count that takes a string and returns a dictionary that maps every case-insensitive word in the str

ing to the number of times it occurs in the string. Don't worry about punctuation, just count it as part of the word it's attached to.
Computers and Technology
1 answer:
Taya2010 [7]3 years ago
5 0

Solution :

We need to write a function named ''$\text{word}$_$\text{count}$". The program takes a string and then returns a dictionary which maps the case insensitive word.

def $\text{word}$_$\text{count}$(s):

   $\text{words}$ = $\text{s.lower}$().split()

   $\text{result}$ = {}

   for $x$ in words:

       if $x$ in $\text{result}$.keys():

           $\text{result}$[x] += 1

       else:

           $\text{result}$[x] = 1

   return $\text{result}$

You might be interested in
Which method call converts the value in variable stringVariable to an integer?
zlopas [31]

Answer:

The correct answer for the given question is Integer.parseInt( string variable );

Explanation:

Integer.parseInt( string variable ); is the method in a java programming language that convert the string into the integer value. It takes a string variable and converted into the integer.

Following are the program in java which convert the string value into an integer value.

class Main  

{

 public static void main(String []args) // main function

{

   String str1 = "10009";

// variable declaration

   int k = Integer.parseInt(str1);

// convert the string into integer.

   System.out.println("Converted into Int:" + k);

}

}

Output:

Converted into Int:10009

Convert.toInt( stringVariable );

Convert.parseInt( stringVariable,Integer.toInt( stringVariable ); are not any method to convert the string into integer .

Therefore the correct answer is :Integer.parseInt( stringVariable );

3 0
3 years ago
Have you ever watched Full House? Who is your favorite character and why? EXPLAIN AND ILL GIVE BRAINLIEST!
liubo4ka [24]

Answer:

havent watched it and thanks for this

Explanation:

7 0
3 years ago
the two main forces acting on a computer that sits on a table are _________ and _________. a. weight; gravity b. weight; mass c.
EleoNora [17]
It is A.weight: gravity
8 0
4 years ago
Read 2 more answers
The concepts of culturally approved goals and the legitimate means of achieving these goals was devised by
xxMikexx [17]

the answer is not C the anwser i have no idea what it is but on my test i got it wrong.

6 0
3 years ago
Read 2 more answers
Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a con
Sophie [7]

Answer:

Explanation:

The following code is written in Java. It creates the three classes as requested with the correct constructors, and getter/setter methods. Then the test class asks the user for all the information and creates the customer object, finally printing out that information from the object getter methods.

import java.util.Scanner;

class Person {

   String name, address, telephone;

   private void Person (String name, String address, String telephone) {

       this.name = name;

       this.address = address;

       this.telephone = telephone;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public String getAddress() {

       return address;

   }

   public void setAddress(String address) {

       this.address = address;

   }

   public String getTelephone() {

       return telephone;

   }

   public void setTelephone(String telephone) {

       this.telephone = telephone;

   }

}

class Customer extends Person {

   String customerNumber;

   Boolean mailingList;

   public Customer(String s, Boolean mail) {

       super();

       this.customerNumber = customerNumber;

       this.mailingList = mailingList;

   }

   public String getCustomerNumber() {

       return customerNumber;

   }

   public void setCustomerNumber(String customerNumber) {

       this.customerNumber = customerNumber;

   }

   public Boolean getMailingList() {

       return mailingList;

   }

   public void setMailingList(Boolean mailingList) {

       this.mailingList = mailingList;

   }

}

class Test {

   public static void main(final String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Customer Name: ");

       String name = in.nextLine();

       System.out.println("Enter Customer Address: ");

       String address = in.nextLine();

       System.out.println("Enter Customer Telephone: ");

       String telephone = in.nextLine();

       System.out.println("Would you like to receive mail? y/n ");

       Boolean mail;

       if(in.nextLine() == "y") {

           mail = true;

       } else {

           mail = false;

       }

       Customer customer = new Customer("1", mail);

       customer.setName(name);

       customer.setAddress(address);

       customer.setTelephone(telephone);

       System.out.println("Name: " + customer.getName());

       System.out.println("Address: " + customer.getAddress());

       System.out.println("Telephone: " + customer.getTelephone());

       System.out.println("Wants to receive mail: " + String.valueOf(customer.getMailingList()));

   }

}

7 0
3 years ago
Other questions:
  • Discuss why mtv initially had a difficulty securing enough ads
    10·1 answer
  • According to the book, if your CPU usage levels are greater than ________ during most of your work session, a faster CPU can gre
    6·1 answer
  • A packet analyzer is a program that can enable a hacker to do all of the following EXCEPT ________. Select one: A. assume your i
    6·1 answer
  • A finance company wants to upgrade its accounting software to a higher version. This version change requires a change in data fo
    15·2 answers
  • Write a method so that the main() code below can be replaced by simpler code that calls method calcMilesTraveled(). Original mai
    11·1 answer
  • Which of these parts serves as the rear cross structure of a vehicle?
    12·1 answer
  • Hello Answerers it would be great if you could answer this:
    12·2 answers
  • The lower band and upper band of integer data type​
    6·1 answer
  • Which of the following is an example of phishing attack? csp
    8·1 answer
  • In cryptocurrency, a block is only considered valid if it has a.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!