Questions Write a separate Python program for each of the following functions, d
ID: 3805344 • Letter: Q
Question
Questions Write a separate Python program for each of the following functions, described in more detail further in this document Function Signature Argument Types T Prints Returns a one Run (n n: int int b experimenter (n, range) Minimum None Maximum, Average (see example below) TC merge (list 1, list 2) listi: list, list2: list list d char Freq (infilepath) infilepaths str character None histogram e output Grid (x) multiplicative grid (see example list f primes (x) x: int g matrix Multiply (m1, m2) m1: 2D list, m2: 2D list 2D listExplanation / Answer
from random import randint
def oneRun(r): #oneRun return a random int between 1 to n
return randint(1,r)
def experimenter(n,r):
nums = []
for i in range(n):
val = oneRun(r)
nums.append(val)
ma = -1
mi = 9999
su = 0.0
print nums # shows the list
for x in nums:
if ma < x:
ma=x
if mi > x:
mi=x
su = su+x
print "Minimun: " + str(mi)
print "Maximum: " + str(ma)
print "Averge: " + str(su/n)
n = input("Input the value of n: ")
r = input("Input the range: ")
experimenter(n,r)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.