Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xst = float(input("start value for x: "))
- xend = float(input("end value for x: "))
- step = float(input(" input step: "))
- #------------------------------------------
- x = xst
- if x>xend :
- print("it is not correct")
- while x<=xend :
- y=x**2#512*x**10-1280*x**8-400*x**4+5*x**2-1
- print("|{:^10}|{:^20}|".format('{:5g}'.format(x),'{:15g}'.format(y)))
- x = x +step
- #---------------------------------------------------
- x = xst
- ymin=x**2#512*x**10-1280*x**8-400*x**4+5*x**2-1
- ymax = ymin
- while x<=xend :
- y=x**2#512*x**10-1280*x**8-400*x**4+5*x**2-1
- if ymin > y:
- ymin = y
- if ymax < y :
- ymax = y
- x = x +step
- print(ymax, ymin)
- #-----------------------------------------------------------------------
- x = xst
- while x<=xend :
- y = x**2#512*x**10-1280*x**8-400*x**4+5*x**2-1
- a= ((y-ymin)*70)/(ymax-ymin)
- a = round(a)
- if (ymax<0) or (ymin> 0):
- print('|{:^10}|'.format('{:5g}'.format(x))+' '*(a-1)+'*')
- if ymin==0 :
- ptint('_'*70)
- else:
- a0= round(((0-ymin)*70)/(ymax-ymin))
- if a0<a :
- print('|{:^10}|'.format('{:5g}'.format(x))+(a0-1)*' '+'|'+(a-a0-2)*' '+'*')
- if a0==a :
- print('|{:^10}|'.format('{:5g}'.format(x))+' '*(a-1)+'*')
- if a0>a :
- print('|{:^10}|'.format('{:5g}'.format(x))+(max(a-1,0))*' '+'*'+(a0-max(a-1,0)-2)*' '+'|')
- #print('|{:^10}|'.format('{:5g}'.format(x))+' '*(a-1)+'*')
- x = x +step
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement