fork download
  1. # Playground for https://stackoverflow.com/a/56313710/11458991
  2.  
  3.  
  4. import math
  5.  
  6.  
  7. x1 = int(input("Enter first number:\n"))
  8. x2 = int(input("Enter second number:\n"))
  9.  
  10. print(" x\ty")
  11. for x in range(x1, x2 + 1):
  12. try:
  13. formula = math.sqrt(x**2 + 3*x - 500)
  14. print("%d\t%.2f" % (x, formula))
  15. except ValueError: # Square root of a negative number.
  16. print("%d\txxx" % x)
  17.  
Success #stdin #stdout 0.03s 9964KB
stdin
15
25
stdout
Enter first number:
Enter second number:
 x	y
15	xxx
16	xxx
17	xxx
18	xxx
19	xxx
20	xxx
21	2.00
22	7.07
23	9.90
24	12.17
25	14.14