Advertisement
Guest User

Untitled

a guest
Dec 13th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1.  
  2.  
  3. import math
  4. import sys
  5. import os
  6. import subprocess
  7. import matplotlib.pyplot as plt
  8. print ("y = a**x")
  9. print ("")
  10. a = input ("Enter 'a' ")
  11. a = float(a)
  12. print ("")
  13. if float(a) < 0:
  14. print ("'a' is negative, no solution")
  15. elif float(a) == 1:
  16. print ("'a' is equal to 1, no solution")
  17. else:
  18. fig = plt.figure ()
  19. i = [-2,-1.75,-1.5,-1.25,-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1,1.25,1.5,1.75,2]
  20. x = i
  21. y = [a**i for i in x]
  22.  
  23.  
  24. ax = fig.add_subplot(1,1,1)
  25.  
  26. ax.plot(x,y)
  27. ax.set_title('y = a**x')
  28. ax.spines['left'].set_position('zero')
  29. ax.spines['right'].set_color('none')
  30. ax.spines['bottom'].set_position('zero')
  31. ax.spines['top'].set_color('none')
  32. ax.spines['left'].set_smart_bounds(True)
  33. ax.spines['bottom'].set_smart_bounds(True)
  34. ax.xaxis.set_ticks_position('bottom')
  35. ax.yaxis.set_ticks_position('left')
  36.  
  37.  
  38. plt.savefig("graph.png")
  39. subprocess.Popen('explorer "C:\\Users\\user\\desktop\\graph.png"')
  40.  
  41. if float (a)<1:
  42. print ("X = R")
  43. print ("Y = (0; inf)")
  44. print ("Xo = Does not exist")
  45. print ("X+ = R")
  46. print ("X- = Does not exist")
  47. print ("X_üles = Does not exist")
  48. print ("X_alla = R")
  49. print ("Xe = Does not exist")
  50. print ("")
  51. elif float (a)>1:
  52. print ("X = R")
  53. print ("Y = (0; inf)")
  54. print ("Xo = Does not exist")
  55. print ("X+ = R")
  56. print ("X- = Does not exist")
  57. print ("X_üles = R")
  58. print ("X_alla = Does not exist")
  59. print ("Xe = Does not exist")
  60. print ("")
  61.  
  62. def restart_program():
  63. python = sys.executable
  64. os.execl(python, python, * sys.argv)
  65.  
  66. if __name__ == "__main__":
  67. answer = input("Restart or close the program ")
  68. if answer.strip() in ["Restart", "restart"]:
  69. restart_program()
  70. else:
  71. os.remove("C:\\Users\\user\\desktop\\graph.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement