Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can I please get help with this code? Any help and pictures of how to run it wou

ID: 3607289 • Letter: C

Question

Can I please get help with this code? Any help and pictures of how to run it would help in Python 2.7.13 00 Verizon 6:32 PM 86%) D + The Science of Competing Living with Cyber Program: Random List Statisties Your task in this programming assignment is to write a Python program that generaties a list of randou integers, such that both its length and the minimum and maximum values added to the list are provided by the user. Subsoquently, display the list, followed by statistics about the list. Hore's output of a sample run (user input is shown in bold red) Bow many randon integers would you 1ike to add to the list? 10 What would you like the miniaus value to be?-50 What would you like The list: 1-46,43. 34,48 7. 31, 36 -11, 39.-9 The mean of the list is 17.2. The median of the ist is 32.5 The range of the liat is 94 the maximun value to be? 50 Hcre's output of a sccond sample run (again, user input is shown in bold red) low many randon integers would you like to add to the list? 7 What would you like the mininn value to be?5 what would yo like the maximun value to be? 999 The list: 1866,666, 47, 661.68. 492, 81 The mean of the liet is 557.285714286 The median of the ist is 661 The range of the 118 785 To help clarify, here are some specifies and or constraints (1) The random integers must be stored in a single Python list (2) Gencrating the random list (including its length, and minimum and maximum valucs) must be done in a function that is called feom the main part of the program (see the template for more details) (3) You must use the list functions discussed in class to add integers to the list (4) Calculating the mcan, median, and range of the list must be done in separate functions, one for each statistie 5) You must mamually cakcuilatie the mean, median, and range of the list (ie, without using math or statistical functions provided in Python libraries) however, you may use list functions to help (6) You must use the provided source code template; and (7) You must submit your source code as a single py file

Explanation / Answer

Here is your python file statistics.py , please maintain indentation while copying in your python console:

from random import randint
import sys

def list_max(nums):
max_v=nums[0]
for x in nums:
if x > max_v:
max_v=x
return max_v
  
def list_min(nums):
min_v=nums[0]
for x in nums:
if x < min_v:
min_v=x
return min_v

def list_mean(nums):
sumof = 0
num_of = len(nums)
mean = 0
for i in nums:
sumof = sumof + i
mean = sumof / num_of
return float(mean)
  
def list_median(nums):
if len(nums)%2 != 0:
return sorted(nums)[len(nums)/2]
else:
midavg = (sorted(nums)[len(nums)/2] + sorted(nums)[len(nums)/2-1])/2.0
return midavg
  
def list_range(nums):
min_val = list_min(nums)
max_val = list_max(nums)

return (min_val, max_val)


print("how many random integers you would like to add to the list")
totalInts =input()

print("what wouls you like minimum number to be")
minNumber =input()

print("what wouls you like maximum number to be")
maxNumber =input()

myList = []

print("The list:")

while len(myList) < totalInts:
item = randint(minNumber, maxNumber)
myList.append(item)
print myList
print "The mean of the list is:", list_mean(myList)
print "The median of the list is:", list_median(myList)
print "The range of the list is:", list_range(myList)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote