Question: # Question 2 Create a function named `count_word` that accepts two arguments `text` and `word`. __Function arguments:__ This function accepts two arguments `text` and `word`.

# Question 2

Create a function named `count_word` that accepts two arguments `text` and `word`.

__Function arguments:__ This function accepts two arguments `text` and `word`. `word` is the argument that your function searches within a given `text` and counts how many times it occurs. `text` is the argument that your functions searches the `word` in and counts its occurance.

__What does it do:__ This function counts how many times a given `word` occurs in a given `text`.

__What it returns:__ It returns the number of times a given `word` occurs in a given `text`. If the word does not occur, return 0.

For Example,

`count_word('Montclair is located in NJ. MOntclair is a great place to live', 'Montclair')`

should return

2

`count_word('Montclair is located in NJ. MOntclair is a great place to live', 'Verona')`

should return

0

__Hints:__ * This question assesses whether or not you understand the strings in Python * You may need specific string operators such as find, split, strip, find, count, etc. to determine if the word is within the text. * If you wish, you can use a for loop to count the number of words within a text. However, using the count operator could be easier.

__Note:__ Your code goes in below cell

# Question 4

Create a function named `get_factorial` that accepts one argument `number`, which is the number of which we would compute the factorial

__Function arguments:__ This function accepts one argument, `number`.

__What does it do:__ Computes the factorial of a given `number`.

__What it returns:__ It returns the factorial of a given `number`

For Example,

`get_factorial(5)`

should return

120

For Example,

`get_factorial(6)`

should return

720

__Hints__ * This question assesses if you understand for loops. * Your goal is to multiply numbers from 1 to a given number * if the number is 4, you will need to multiply 1, 2, 3, and 4, and return 24. If the number is 6, you will multiply 1, 2, 3, 4, 5, 6, and return 720. * You may need to use a while loop. * Recall that 0! is 1. so if the number is 0, you need to return 1. * Some examples * 0!=1 * 1!=1 * 2!=2.1=1 * 3!=3.2.1=6 * 4!=4.3.2.1=24

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!