Advertisement
electricmaster

Assignment4.py

Dec 2nd, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. from random import *
  2.  
  3. seed(42)
  4. numbers = [75, -18, 216, 21, -6, 352, 39, -68, -318, 182]
  5.  
  6. def nonrand(i):
  7.     return numbers[i]
  8.  
  9. def rand():
  10.     return randint(-999, 999)
  11.  
  12. def mean(a):
  13.     return float(sum(a)) / max(len(a), 1)
  14.  
  15.  
  16. x = [nonrand(i) for i in range(10)]
  17. y = [rand() for i in range(10)]
  18. x.sort()
  19. y.sort()
  20.  
  21. print '\tNONRAND\tRAND\n'
  22. print 'MIN\t', x[0], '\t', y[0], '\n'
  23. print 'MAX\t', x[9], '\t', y[9], '\n'
  24. print 'MEAN\t', mean(x), '\t', mean(y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement