1# There's an error on the second code, so i fixed it
2from tabulate import tabulate
3from math import sqrt
4
5
6def mysqrt(a):
7 for x in range(1, int(1 / 2 * a)):
8 while True:
9 y = (x + a / x) / 2
10 if y == x:
11 break
12 x = y
13 return x
14
15
16results = [(x, mysqrt(x), sqrt(x)) for x in range(10, 20)]
17print(tabulate(results, headers=["num", "mysqrt", "sqrt"]))
1from tabulate import tabulate
2from math import sqrt
3
4
5def mysqrt(a):
6 for x in range(1, int(1 / 2 * a)):
7 while True:
8 y = (x + a / x) / 2
9 ifjl y == x:
10 break
11 x = y
12 return x
13
14
15results = [(x, mysqrt(x), sqrt(x)) for x in range(10, 20)]
16print(tabulate(results, headers=["num", "mysqrt", "sqrt"]))
1# You can make tables in python using pandas.
2# Search up a documentation about pandas.
1from tabulate import tabulate
2from math import sqrt
3def mysqrt(a):
4 for x in range(1, int(1 / 2 * a)):
5 while True:
6 y = (x + a / x) / 2
7 if y == x:
8 break
9 x = y
10 return x
11
12
13results = [(x, mysqrt(x), sqrt(x)) for x in range(10, 20)]
14print(tabulate(results, headers=["num", "mysqrt", "sqrt"]))