Question: # Question 6 Create a function named `is_even` that accepts one argument `number` to check if it is even __Function arguments:__ This function accepts one

# Question 6

Create a function named `is_even` that accepts one argument `number` to check if it is even

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

__What does it do:__ check if the `number` is even

__What it returns:__ It returns 1 if the number is even. Otherwise, -1.

For Example,

`is_even(7)`

should return

-1

For Example,

`is_even(12)`

should return

1

__Hint:__* You need to use the modulus operator that gives the remainder (%) * Also recall how we decide if a number is odd or even. We need to divide the number by 2 and check the remainder. If the remainder is 0, then the number is even. We can do this using the % operator

7.

# Question 7

Create a function named `is_odd` that accepts one argument `number` to check if it is odd

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

__What does it do:__ check if the `number` is odd

__What it returns:__ It returns 1 if the number is odd. Otherwise, -1.

For Example,

`is_odd(7)`

should return

1

For Example,

`is_odd(12)`

should return

-1

__Hint:__

* This is the same question above. All you need to do is to flip the signs. * You need to use the modulus operator that gives the remainder (%) * Also recall how we decide if a number is odd or even. We need to divide the number by 2 and check the remainder. If the remainder is 0, then the number is even. We can do this using the % operator

#8

Create a function named `get_std` that accepts one argument `s_list` and computes the standard deviation of the numbers within the `s_list` __FROM SCARTCH__

__Function arguments:__ This function accepts one argument `s_list`

__What does it do:__ Computes the standard deviation of the numbers within `s_list` __FROM SCARTCH__

__What it returns:__ It returns the standard deviation.

For Example,

`get_std([3, 3 , 3, 3])`

should return

0

For Example,

`get_std(12, 5, 8 )`

should return

3.51

__Hint:__

1. find the mean of the numbers 2. subtract the mean from each numbers 3. square the differences 4. sum the differences 5. divide by (the size (len) of the list - 1) 6. if there are 5 items in the list, divide it by 4 7. take the square root of the result 8. return it

------

Create a function named `get_range` that accepts one argument `r_list` and computes the range of the numbers within the `r_list` __FROM SCARTCH__

__Function arguments:__ This function accepts one argument `r_list`

__What does it do:__ Computes the range of the numbers within `r_list` __FROM SCARTCH __

__What it returns:__ It returns the range

For Example,

`get_range([3, 3 , 3, 3])`

should return

0

For Example,

`get_range(12, 5, 8 )`

should return

# 10

Create a function named `get_common_words` that accepts two arguments `text1` and `text2`. This function finds the common words occuring both in `text1` and `text2`

__Function arguments:__ This function accepts two arguments `text1` and `text2`.

__What does it do:__ Finds the common words occuring both in `text1` and `text2`

__What it returns:__ It returns the common words in lower case in a __LIST__

For Example,

`get_common_words('I love New Jersey', 'You Love Philly`)

should return

['love']

For Example,

`get_common_words('I like New Jersey', 'I like Philly`)

should return

['I', 'like']

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!