1 distraction is phones , texting and driving . They could have a system in their car which activated by a voice assistant who could do it al for them
Answer:
import numpy as np
def sample_median(n, P):
return np.median( np.random.choice ( np.arange (1, len(P) + 1 ), n, p = P ) )
print(sample_median(10,[0.1 0.2 0.1 0.3 0.1 0.2]))
print(sample_median(10,[0.1 0.2 0.1 0.3 0.1 0.2]))
print(sample_median(5, [0.3,0.7])
print(sample_median(5, [0.3,0.7])
Explanation:
- Bring in the numpy library to use the median function provided by the numpy library.
- Define the sample_median function that takes in 2 parameters and returns the median with the help of built-in random, choice and arrange functions.
- Call the sample_median function by providing some values to test and then display the results.
Output:
4.5
4.0
2.0
1.0
Answer:
Statement:
print("first is "+str(first)+" second = "+str(second)) # It is a python statement where first and second are variable of any type.
Explanation:
- The above statement is the print statement that prints the value of first and second variables like in the form of "first is" value of the first variable, then space, then "second = b" and then the value of the second variable.
- The value for the first and the second variable of any type but it convert it into string form with the help of str() function in the print statement.
- The string of the print statement can be formed by the help '+' operator which adds the string with the value and the other string in print statement in java and python language.