-4

How would I:

Write a function that will take a single parameter of an integer, and return a list of that many random numbers between 1 and 100.

Using this function, write a program that will store 50 random numbers in a list, and then calculate and print out the average of all the numbers.

Community
  • 1
  • 1
Emma
  • 9
  • 2
    Please read [ask] - you are expected to show your own attempt. – Filburt Oct 25 '16 at 11:34
  • import random number =int(input("Please enter a number")) def myfunction(number): output = [] return output[random.randint(number)] for x in range(1): – Emma Oct 25 '16 at 11:47
  • Edit your question to include properly formatted code. Are you really using Python-2.3? I just you upgrade to a later version – Chris_Rands Oct 25 '16 at 11:58

1 Answers1

0

Below a solution using numpy array :

import numpy as np

def randomx(nb):
    random_array = np.random.randint(1, 100, nb)
    print mean(random_array)
Chr
  • 875
  • 1
  • 10
  • 27