>>> import random >>> # never: from random import * >>> >>> # add up 10 random numbers >>> total = 0 >>> for i in range(10): ... total += random.randrange(1,7) # includes 1, excludes 7 ... >>> total 44 >>> for i in range(10): ... total += random.randrange(1,7) # includes 1, excludes 7 ... >>> total 78 >>> rolls = [random.randrange(1,7) for i in range(10)] >>> rolls [6, 1, 5, 2, 4, 5, 4, 5, 4, 4] >>> rolls = [random.randrange(1,7) for i in range(10)] >>> rolls [5, 2, 6, 3, 5, 3, 3, 6, 6, 5] >>> >>> import matplotlib.pyplot as plt >>> plt.plot(range(10), rolls) # x-values, y-values [] >>> plt.show() >>> plt.clf() >>> plt.scatter(range(10), rolls) # x-values, y-values >>> plt.show() >>> >>> x_vals = range(10) >>> import math >>> y_vals = [math.exp(x) for x in x_vals] >>> plt.plot(x_vals, y_vals) [] >>> >>> plt.show()