Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1.  
  2.  
  3. xst = float(input("start value for x: "))
  4.  
  5. xend = float(input("end value for x: "))
  6.  
  7. step = float(input(" input step: "))
  8. #------------------------------------------
  9. x = xst
  10.  
  11. if x>xend :
  12. print("it is not correct")
  13.  
  14. while x<=xend :
  15. y=x**2#512*x**10-1280*x**8-400*x**4+5*x**2-1
  16. print("|{:^10}|{:^20}|".format('{:5g}'.format(x),'{:15g}'.format(y)))
  17. x = x +step
  18. #---------------------------------------------------
  19. x = xst
  20. ymin=x**2#512*x**10-1280*x**8-400*x**4+5*x**2-1
  21. ymax = ymin
  22. while x<=xend :
  23. y=x**2#512*x**10-1280*x**8-400*x**4+5*x**2-1
  24. if ymin > y:
  25. ymin = y
  26. if ymax < y :
  27. ymax = y
  28. x = x +step
  29. print(ymax, ymin)
  30. #-----------------------------------------------------------------------
  31. x = xst
  32. while x<=xend :
  33. y = x**2#512*x**10-1280*x**8-400*x**4+5*x**2-1
  34. a= ((y-ymin)*70)/(ymax-ymin)
  35. a = round(a)
  36. if (ymax<0) or (ymin> 0):
  37. print('|{:^10}|'.format('{:5g}'.format(x))+' '*(a-1)+'*')
  38. if ymin==0 :
  39. ptint('_'*70)
  40. else:
  41. a0= round(((0-ymin)*70)/(ymax-ymin))
  42. if a0<a :
  43. print('|{:^10}|'.format('{:5g}'.format(x))+(a0-1)*' '+'|'+(a-a0-2)*' '+'*')
  44. if a0==a :
  45. print('|{:^10}|'.format('{:5g}'.format(x))+' '*(a-1)+'*')
  46. if a0>a :
  47. print('|{:^10}|'.format('{:5g}'.format(x))+(max(a-1,0))*' '+'*'+(a0-max(a-1,0)-2)*' '+'|')
  48.  
  49. #print('|{:^10}|'.format('{:5g}'.format(x))+' '*(a-1)+'*')
  50. x = x +step
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement