+ 1

Why do i get an error?

import numpy as np import random a = random.randint(10, 100, 10) range = np.max(a) - np.min(a) mean = np.mean(a) std1 = np.std(a) print("The range is " + str(range)) print("The mean and standard deviation of the distribution are " + str(mean) + " and " + str(std1) + ".")

8th Mar 2019, 5:05 AM
Rizan
Rizan - avatar
1 Answer
+ 9
The randint() method of the random module only takes 2 arguments: low and high. The numpy module includes the random.randint() method which takes low and high and size (and dtype, default is int). So to fix your code: dont bother with 'import random' just change 'random.randint(' to 'np.random.randint('
8th Mar 2019, 5:42 AM
David Ashton
David Ashton - avatar