-1
import math
def newtons_method(a):
 #a = int(input("Enter the value of a :"))
 x = int(input("Enter the value of x :"))

 while True:
               print (x)
               y = (x + a/x) / 2
               if y == x:
                   return float(y)
                   break
               x = y
def mathlibs(a):
     result = math.sqrt(a)
     return float(result)

def test_square_root(a):
    A = newtons_method(a)
    B = mathlibs(a)
    print(B)
    Difference = B-A
    answers = list()
    answer = ''


    print('{:<10s}{:>50s}{:>30s}{:>20s}'.format('a','square root newton method','sqrtlibrary','Difference'))
    answer = print('{:<10f}{:>50f}{:>30f}{:>20f}'.format(a,A,B,Difference))
    answers.append(answer)
    print(answers)

test_square_root(565)
hiro protagonist
  • 44,693
  • 14
  • 86
  • 111
  • 2
    Welcome to Stack Overflow. Have you read [how to ask a question](https://stackoverflow.com/help/how-to-ask)? Please at least include some text in your question, provide a [mre], and [format](https://meta.stackexchange.com/editing-help#syntax-highlighting) your code correctly (especially for Python code, because indenting is part of the language!). Regarding your code, what do you think that `print` returns? – wovano Jun 23 '19 at 15:14

1 Answers1

0

Hello and welcome to Stack Overflow.

I am guessing that you need to store your answers even after your program terminates. You could create a file and append your answers for the following executions of your square program. Refer to this link.

Alternatively, if you want to get fancier about your program import sqlite3 to create a database table for your answers.

Sıddık Açıl
  • 957
  • 8
  • 18
  • Hi , your're right, i need to store my answers and print them so that it appears as a long list – Kumaran Jun 23 '19 at 15:31