Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import sys
- import os
- import subprocess
- import matplotlib.pyplot as plt
- print ("y = a**x")
- print ("")
- a = input ("Enter 'a' ")
- a = float(a)
- print ("")
- if float(a) < 0:
- print ("'a' is negative, no solution")
- elif float(a) == 1:
- print ("'a' is equal to 1, no solution")
- else:
- fig = plt.figure ()
- 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]
- x = i
- y = [a**i for i in x]
- ax = fig.add_subplot(1,1,1)
- ax.plot(x,y)
- ax.set_title('y = a**x')
- ax.spines['left'].set_position('zero')
- ax.spines['right'].set_color('none')
- ax.spines['bottom'].set_position('zero')
- ax.spines['top'].set_color('none')
- ax.spines['left'].set_smart_bounds(True)
- ax.spines['bottom'].set_smart_bounds(True)
- ax.xaxis.set_ticks_position('bottom')
- ax.yaxis.set_ticks_position('left')
- plt.savefig("graph.png")
- subprocess.Popen('explorer "C:\\Users\\user\\desktop\\graph.png"')
- if float (a)<1:
- print ("X = R")
- print ("Y = (0; inf)")
- print ("Xo = Does not exist")
- print ("X+ = R")
- print ("X- = Does not exist")
- print ("X_üles = Does not exist")
- print ("X_alla = R")
- print ("Xe = Does not exist")
- print ("")
- elif float (a)>1:
- print ("X = R")
- print ("Y = (0; inf)")
- print ("Xo = Does not exist")
- print ("X+ = R")
- print ("X- = Does not exist")
- print ("X_üles = R")
- print ("X_alla = Does not exist")
- print ("Xe = Does not exist")
- print ("")
- def restart_program():
- python = sys.executable
- os.execl(python, python, * sys.argv)
- if __name__ == "__main__":
- answer = input("Restart or close the program ")
- if answer.strip() in ["Restart", "restart"]:
- restart_program()
- else:
- os.remove("C:\\Users\\user\\desktop\\graph.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement