makispaiktis

Magics Show Graph

Sep 22nd, 2020 (edited)
815
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''
  2. Magic
  3. 1) x, 2) x + 11, 3) x + 6, 4) x^2 + 6x, 5) x^2 + 6x + 9, 6) x + 3, 7) x + 4, 8) x
  4. '''
  5. from math import sqrt
  6. from matplotlib import pyplot as plt
  7.  
  8. def magic(number):
  9.     results = list()
  10.     results.append(number)                               # 1
  11.     results.append(results[0] + 11)                 # 2
  12.     results.append(results[1] - 5)                  # 3
  13.     results.append(results[2] * results[0])         # 4
  14.     results.append(results[3] + 9)                  # 5
  15.     results.append(int(sqrt(results[4])))           # 6
  16.     results.append(results[5] + 1)                  # 7
  17.     results.append(results[6] - results[0])         # 8
  18.     return results
  19.  
  20. # MAIN FUNCTION
  21. numbers = list(range(1, 101))
  22. magics = list()
  23. for number in numbers:
  24.     magics.append(magic(number))
  25. for magic in magics:
  26.     plt.plot(magic)
  27. plt.show()
RAW Paste Data