Question: python Question 2: There are 5 parts to this question. Write the following functions. Q2a. Function name question_2a Parameter(s) argument(s) In this order, 1. a

python

python Question 2: There are 5 parts to this question. Write the

following functions. Q2a. Function name question_2a Parameter(s) argument(s) In this order, 1.

a list of integers 2. an integer Return value An integer Detailed

description return the number of times the given integer appears in the

Question 2: There are 5 parts to this question. Write the following functions. Q2a. Function name question_2a Parameter(s) argument(s) In this order, 1. a list of integers 2. an integer Return value An integer Detailed description return the number of times the given integer appears in the given list Example usage question_2a([1,5,2,-1,99,5,0],-1) 1 Example's return value Q2b. Function name dot_product Parameter(s) argument(s) In this order, 1. a list of N integers 2. a list of N integers Return value An integer Detailed description Given: list1 = (au, az, az, as, ...) an] list2 - [bu, bz, bs, bas ..., by] A dot product is defined as such a.*b + az*b2 + az*b3 ... + anton Return dot product of the two lists. You can assume the list parameters are of the same length and N>0. Example usage dot_product([1,2,3,4,5), (9,8,7,6,-5]) Example's return value 45 Because 1*9+2*8+3*7+4*6+5*-5 = 45 Q2c. Function name rms Parameter(s) argument(s) 1. A list of integers Return value 1. A float Detailed description Given a list: list1 = (ai, az, a, a, ..., an] The root mean square of a list of numbers is defined as such ca 2 + az2 + az2 + 2q2 + - + ax?) Return the root mean square of the list of integers. There is no need to format the number of decimal places in a float. Example usage rms([1,2,3,4,5,6,7]) 4.47213595499958 Example's return value Q2d. Function name key_value_pairs Parameter(s) argument(s) 1. A list of lists, each containing two elements. e.g. [[ao, a1],[60,61], ...] Return value A dictionary Detailed description Example usage Using the first elements of each nested list as keys and the second elements as values, return a dictionary that contains all the key-value pairs. key_value_pairs([["Sputnik V", 0.916], ["Pfizer",0.95], ["Moderna",0.94]])) {"Sputnik V":0.916, "Pfizer":0.95, "Moderna" :0.94} Example's return value Q2e. Function name question_2e Parameter(s) argument(s) No parameters for this function Return value A str Detailed description Get a user input with the prompt "Enter a number: " You may assume the user input will be a positive numeric integers Base on the value, x, obtained from the user input, return the following character(s) as stated in the table below. if x is divisible by 7 "7-up" if x is divisible by 3 "Crowd if x is divisible by 2 Even" None of the above "NA" Example usage x = question_2e() (user input is print(x) indicated in bold) Enter a number: 7 Example usage's console output 7-up

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 Databases Questions!