def factorial(n):
space = ' ' * (4 * n)
print(space, 'factorial', n)
if n == 0:
print(space, 'returning 1')
return 1
else:
recurse = factorial(n-1)
result = n * recurse
print(space, 'returning', result)
return result
print(factorial(5))
def ferm():
a=input("please enter a value for a\n")
a=int(a)
b=input("please enter a value for b\n")
b=int(b)
c=input("please enter a value for c\n")
c=int(c)
n=input("please enter a value for n\n")
n=int(n)
if n <=2 and a**n + b**n == c**n:
return "aferin canavar, buldun!"
elif n >2 and a**n + b**n == c**n:
return "Holy smokes, Fermat was wrong!"
else:
return "No, that doesn’t work."
print(ferm())
# Write a function that prompts the user to input values for a, b, c and n, converts them to integers, and uses check_fermat
# to check whether they violate Fermat’s theorem.
def ferm(a,b,c,n):
if n <= 2 and a**n + b**n == c**n:
return "hell yeah!"
elif n > 2 and a**n + b**n == c**n:
return "Holy smokes, Fermat was wrong!"
else:
return "No, that doesn’t work."
def fermin():
a=input("please enter a value for a\n")
a=int(a)
b=input("please enter a value for b\n")
b=int(b)
c=input("please enter a value for c\n")
c=int(c)
n=input("please enter a value for n\n")
n=int(n)
return ferm(a,b,c,n)
print(fermin())
import math
def distance(xc, yc, xp, yp):
dx = xp - xc
dy = yp - yc
dsquared = dx**2 + dy**2
result = math.sqrt(dsquared)
print(result)
return result
def area(radius):
return math.pi * radius**2
def circle_area(xc, yc, xp, yp):
return area(distance(xc, yc, xp, yp))
circle_area(5, 7, 2, 9)
import math
print ()
print ("a", " "*2, "mysqrt(a) ", ""*5, "math.sqrt(a) ", " "*1, "diff")
print ("-", " "*2, "-----------------", ""*5, "----------------", " "*2, "------")
a = 1
while a < 10:
def mysqrt(a):
x = 6
while True:
y = (x + a/x) / 2
if y == x:
break
x = y
return x
def test_square_root(a):
diff=abs(mysqrt(a)-math.sqrt(a))
while diff < 0.005:
return a, mysqrt(a), math.sqrt(a), diff
print(test_square_root(a))
a = a+1
import math
print ()
print ("a", " "*2, "mysqrt(a) ", ""*5, "math.sqrt(a) ", " "*1, "diff")
print ("-", " "*2, "-----------------", ""*5, "----------------", " "*2, "------")
def mysqrt(a):
x = 6
while True:
y = (x + a/x) / 2
if y == x:
break
x = y
return x
def test_square_root(a):
diff=abs(mysqrt(a)-math.sqrt(a))
if diff < 0.005:
return a, mysqrt(a), math.sqrt(a), diff
for a in range(1, 10):
print(test_square_root(a))
def factorial(n):
space = ' ' * (4 * n)
print(space, 'factorial', n)
if n == 0:
print(space, 'returning 1')
return 1
else:
recurse = factorial(n-1)
result = n * recurse
print(space, 'returning', result)
return result
print(factorial(5))
def ferm():
a=input("please enter a value for a\n")
a=int(a)
b=input("please enter a value for b\n")
b=int(b)
c=input("please enter a value for c\n")
c=int(c)
n=input("please enter a value for n\n")
n=int(n)
if n <=2 and a**n + b**n == c**n:
return "aferin canavar, buldun!"
elif n >2 and a**n + b**n == c**n:
return "Holy smokes, Fermat was wrong!"
else:
return "No, that doesn’t work."
print(ferm())
# Write a function that prompts the user to input values for a, b, c and n, converts them to integers, and uses check_fermat
# to check whether they violate Fermat’s theorem.
def ferm(a,b,c,n):
if n <= 2 and a**n + b**n == c**n:
return "hell yeah!"
elif n > 2 and a**n + b**n == c**n:
return "Holy smokes, Fermat was wrong!"
else:
return "No, that doesn’t work."
def fermin():
a=input("please enter a value for a\n")
a=int(a)
b=input("please enter a value for b\n")
b=int(b)
c=input("please enter a value for c\n")
c=int(c)
n=input("please enter a value for n\n")
n=int(n)
return ferm(a,b,c,n)
print(fermin())
import math
def distance(xc, yc, xp, yp):
dx = xp - xc
dy = yp - yc
dsquared = dx**2 + dy**2
result = math.sqrt(dsquared)
print(result)
return result
def area(radius):
return math.pi * radius**2
def circle_area(xc, yc, xp, yp):
return area(distance(xc, yc, xp, yp))
circle_area(5, 7, 2, 9)
import math
print ()
print ("a", " "*2, "mysqrt(a) ", ""*5, "math.sqrt(a) ", " "*1, "diff")
print ("-", " "*2, "-----------------", ""*5, "----------------", " "*2, "------")
a = 1
while a < 10:
def mysqrt(a):
x = 6
while True:
y = (x + a/x) / 2
if y == x:
break
x = y
return x
def test_square_root(a):
diff=abs(mysqrt(a)-math.sqrt(a))
while diff < 0.005:
return a, mysqrt(a), math.sqrt(a), diff
print(test_square_root(a))
a = a+1
import math
print ()
print ("a", " "*2, "mysqrt(a) ", ""*5, "math.sqrt(a) ", " "*1, "diff")
print ("-", " "*2, "-----------------", ""*5, "----------------", " "*2, "------")
def mysqrt(a):
x = 6
while True:
y = (x + a/x) / 2
if y == x:
break
x = y
return x
def test_square_root(a):
diff=abs(mysqrt(a)-math.sqrt(a))
if diff < 0.005:
return a, mysqrt(a), math.sqrt(a), diff
for a in range(1, 10):
print(test_square_root(a))
def factorial(n):
space = ' ' * (4 * n)
print(space, 'factorial', n)
if n == 0:
print(space, 'returning 1')
return 1
else:
recurse = factorial(n-1)
result = n * recurse
print(space, 'returning', result)
return result
print(factorial(5))
def ferm():
a=input("please enter a value for a\n")
a=int(a)
b=input("please enter a value for b\n")
b=int(b)
c=input("please enter a value for c\n")
c=int(c)
n=input("please enter a value for n\n")
n=int(n)
if n <=2 and a**n + b**n == c**n:
return "aferin canavar, buldun!"
elif n >2 and a**n + b**n == c**n:
return "Holy smokes, Fermat was wrong!"
else:
return "No, that doesn’t work."
print(ferm())
# Write a function that prompts the user to input values for a, b, c and n, converts them to integers, and uses check_fermat
# to check whether they violate Fermat’s theorem.
def ferm(a,b,c,n):
if n <= 2 and a**n + b**n == c**n:
return "hell yeah!"
elif n > 2 and a**n + b**n == c**n:
return "Holy smokes, Fermat was wrong!"
else:
return "No, that doesn’t work."
def fermin():
a=input("please enter a value for a\n")
a=int(a)
b=input("please enter a value for b\n")
b=int(b)
c=input("please enter a value for c\n")
c=int(c)
n=input("please enter a value for n\n")
n=int(n)
return ferm(a,b,c,n)
print(fermin())
import math
def distance(xc, yc, xp, yp):
dx = xp - xc
dy = yp - yc
dsquared = dx**2 + dy**2
result = math.sqrt(dsquared)
print(result)
return result
def area(radius):
return math.pi * radius**2
def circle_area(xc, yc, xp, yp):
return area(distance(xc, yc, xp, yp))
circle_area(5, 7, 2, 9)
import math
print ()
print ("a", " "*2, "mysqrt(a) ", ""*5, "math.sqrt(a) ", " "*1, "diff")
print ("-", " "*2, "-----------------", ""*5, "----------------", " "*2, "------")
a = 1
while a < 10:
def mysqrt(a):
x = 6
while True:
y = (x + a/x) / 2
if y == x:
break
x = y
return x
def test_square_root(a):
diff=abs(mysqrt(a)-math.sqrt(a))
while diff < 0.005:
return a, mysqrt(a), math.sqrt(a), diff
print(test_square_root(a))
a = a+1
import math
print ()
print ("a", " "*2, "mysqrt(a) ", ""*5, "math.sqrt(a) ", " "*1, "diff")
print ("-", " "*2, "-----------------", ""*5, "----------------", " "*2, "------")
def mysqrt(a):
x = 6
while True:
y = (x + a/x) / 2
if y == x:
break
x = y
return x
def test_square_root(a):
diff=abs(mysqrt(a)-math.sqrt(a))
if diff < 0.005:
return a, mysqrt(a), math.sqrt(a), diff
for a in range(1, 10):
print(test_square_root(a))
def factorial(n):
space = ' ' * (4 * n)
print(space, 'factorial', n)
if n == 0:
print(space, 'returning 1')
return 1
else:
recurse = factorial(n-1)
result = n * recurse
print(space, 'returning', result)
return result
print(factorial(5))
def ferm():
a=input("please enter a value for a\n")
a=int(a)
b=input("please enter a value for b\n")
b=int(b)
c=input("please enter a value for c\n")
c=int(c)
n=input("please enter a value for n\n")
n=int(n)
if n <=2 and a**n + b**n == c**n:
return "aferin canavar, buldun!"
elif n >2 and a**n + b**n == c**n:
return "Holy smokes, Fermat was wrong!"
else:
return "No, that doesn’t work."
print(ferm())
# Write a function that prompts the user to input values for a, b, c and n, converts them to integers, and uses check_fermat
# to check whether they violate Fermat’s theorem.
def ferm(a,b,c,n):
if n <= 2 and a**n + b**n == c**n:
return "hell yeah!"
elif n > 2 and a**n + b**n == c**n:
return "Holy smokes, Fermat was wrong!"
else:
return "No, that doesn’t work."
def fermin():
a=input("please enter a value for a\n")
a=int(a)
b=input("please enter a value for b\n")
b=int(b)
c=input("please enter a value for c\n")
c=int(c)
n=input("please enter a value for n\n")
n=int(n)
return ferm(a,b,c,n)
print(fermin())
import math
def distance(xc, yc, xp, yp):
dx = xp - xc
dy = yp - yc
dsquared = dx**2 + dy**2
result = math.sqrt(dsquared)
print(result)
return result
def area(radius):
return math.pi * radius**2
def circle_area(xc, yc, xp, yp):
return area(distance(xc, yc, xp, yp))
circle_area(5, 7, 2, 9)
import math
print ()
print ("a", " "*2, "mysqrt(a) ", ""*5, "math.sqrt(a) ", " "*1, "diff")
print ("-", " "*2, "-----------------", ""*5, "----------------", " "*2, "------")
a = 1
while a < 10:
def mysqrt(a):
x = 6
while True:
y = (x + a/x) / 2
if y == x:
break
x = y
return x
def test_square_root(a):
diff=abs(mysqrt(a)-math.sqrt(a))
while diff < 0.005:
return a, mysqrt(a), math.sqrt(a), diff
print(test_square_root(a))
a = a+1
import math
print ()
print ("a", " "*2, "mysqrt(a) ", ""*5, "math.sqrt(a) ", " "*1, "diff")
print ("-", " "*2, "-----------------", ""*5, "----------------", " "*2, "------")
def mysqrt(a):
x = 6
while True:
y = (x + a/x) / 2
if y == x:
break
x = y
return x
def test_square_root(a):
diff=abs(mysqrt(a)-math.sqrt(a))
if diff < 0.005:
return a, mysqrt(a), math.sqrt(a), diff
for a in range(1, 10):
print(test_square_root(a))