Question

In: Computer Science

# Do not delete this cell. You have to run this cell to test your code...

# Do not delete this cell. You have to run this cell to test your code in the test cases.
score = dict()

# This function will search the given text in order to find a given word

def is_word_there(text, word):
  
    """
        What it takes?
            a text to be searched
            a word to be searched within a text
          
        what it does?
            searches if a word occurs in a text
          
        What it returns?
            returns 1 if word is in the text.
            returns -1 if word is not in the text
    """
  
    # your code goes in here
  
    return
   

Test Case for Question 1. Do not delete or alter the cell below

score = dict()

text = """ Python is an amazing programming language.
            Python is also one of the primary languages in the data analysis field"""

word = "amazing"

try:
    if is_word_there(text, word) ==1:
        score['question 1'] = 'pass'
    else:
        score['question 1'] = 'fail'
except:
    score['question 1'] = 'fail'
  
is_word_there(text, word)

Solutions

Expert Solution


# Do not delete this cell. You have to run this cell to test your code in the test cases.

# This function will search the given text in order to find a given word
def is_word_there(text, word):
  """
    What it takes?
      a text to be searched
      a word to be searched within a text
    
    what it does?
      searches if a word occurs in a text
      
    What it returns?
      returns 1 if word is in the text.
      returns -1 if word is not in the text
  """
  # your code goes in here
  text_to_array = text.split()
  if word in text_to_array:
    return 1
  else:
    return -1
   

score = dict()

text = """ Python is an amazing programming language. Python is also one of the primary languages in the data analysis field"""
word = "amazing"

try:
  if is_word_there(text, word) == 1:
    score['question 1'] = 'pass'
  else:
    score['question 1'] = 'fail'
except:
  score['question 1'] = 'fail'
  
is_word_there(text, word)

# test command
print(score)


Related Solutions

How do you run an ANOVA test when some of the values are non-numeric? I have...
How do you run an ANOVA test when some of the values are non-numeric? I have a large excel database, over 100,000 cells worth of data. For the assignment, I need to see if there is a relation between the type of distribution channel (non-numeric) and the average amount of money spent (numeric). I HAVE to use ANOVA to solve this but I am not sure how. There are 11 different distribution channels and 100,000 different values for the amount...
Run the following code and explain the results (expectation of the array). Test it on the...
Run the following code and explain the results (expectation of the array). Test it on the following arrays: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] [1.0, 4.0, 6.0,2.0 , 3.0, 5.0] [5.0, 3.0, 2.0, 6.0, 4.0, 1.0] [6.0, 5.0, 4.0, 3.0, 2.0, 1.0] // Java code to calculate expected // value of an array import java.io.*; class GFG { // Function to calculate expectation static float calc_Expectation(float a[], float n) { // Variable prb is for probability of each // element...
TEST YOUR VPNs 1. You have earlier created two VPNs. How do you know your VPNs...
TEST YOUR VPNs 1. You have earlier created two VPNs. How do you know your VPNs are configured correctly? There are several ways you can check whether your VPN is working properly but it is important you use reliable and reputable online tools that give accurate results. Follow the steps below to check VPNs are correctly set up.  Basic IP Address Test a. First, before connecting to your VPN, visit an IP check page, and note the IP address...
The following code will generate a Decision Tree. You need to run the code and explain...
The following code will generate a Decision Tree. You need to run the code and explain the tree. After you get the Tree. You need to explain how does it draw like that. install.packages("rpart.plot") # install package rpart.plot ########################################## # section 7.1.1 Overview of a Decision Tree ########################################## library("rpart") library("rpart.plot") # Read the data setwd("c:/data/") banktrain <- read.table("bank-sample-test.csv",header=TRUE,sep=",") ## drop a few columns to simplify the tree drops<-c("age", "balance", "day", "campaign", "pdays", "previous", "month") banktrain <- banktrain [,!(names(banktrain) %in% drops)]...
---In the code, create add and delete a student by ID number when prompted /////////////////////////////////////////////////////////////// import...
---In the code, create add and delete a student by ID number when prompted /////////////////////////////////////////////////////////////// import java.util.Scanner; public class COurseCom666 {     private String courseName;     private String [] students = new String[1];     private int numberOfStudents;     public COurseCom66(String courseName) {         this.courseName = courseName;     }     public String[] getStudents() {         return students;     }     public int getNumberOfStudents() {         return numberOfStudents;     }     public String getCourseName() {         return courseName;     }     public...
10) What test should you run to determine if your residuals are not spatially dependent (i.e....
10) What test should you run to determine if your residuals are not spatially dependent (i.e. they are independent)? If that test proves to be significant, what corrective action can you take?
You are planning to estimate a short- run production function for your firm, and you have...
You are planning to estimate a short- run production function for your firm, and you have collected the following data on labor usage (L) and output (Q): Labor usage (L) Output (Q) 3 1 7 2 9 3 11 5 17 8 17 10 20 15 24 18 26 22 28 21 30 23 a. Please key in the data into MS Excel for regression analysis. Estimate your firm’s short-run production function. Do the parameter estimates have the appropriate algebraic...
You are planning to estimate a short- run production function for your firm, and you have...
You are planning to estimate a short- run production function for your firm, and you have collected the following data on labor usage (L) and output (Q): Labor usage (L) Output (Q) 3 1 7 2 9 3 11 5 17 8 17 10 22 15 24 18 26 22 28 21 30 20 33 19 34 17 a. Please key in the data into MS Excel for regression analysis. Estimate your firm’s short-run production function. Do the parameter estimates...
You are planning to estimate a short- run production function for your firm, and you have...
You are planning to estimate a short- run production function for your firm, and you have collected the following data on labor usage (L) and output (Q): Labor usage Output 3 1 7 2 9 3 11 5 17 8 17 10 20 15 24 18 26 22 28 21 30 23 a. Please key in the data into MS Excel for regression analysis. Estimate your firm’s short-run production function. Do the parameter estimates have the appropriate algebraic signs? Are...
Please do it in C++. Please comment on the code, and comments detail the run time...
Please do it in C++. Please comment on the code, and comments detail the run time in terms of total operations and Big O complexities. 1. Implement a class, SubstitutionCipher, with a constructor that takes a string with the 26 uppercase letters in an arbitrary order and uses that as the encoder for a cipher (that is, A is mapped to the first character of the parameter, B is mapped to the second, and so on.) Please derive the decoding...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT