Mar-19-2018, 02:11 PM
I am trying to use a specific formula that sort of uses it self over and over, been trying to figue it out on my own please help me. Thank you
import math def main(): for i in range(20): x0 = 0.375 x0 = NR(x0) print(format(x0, '.3f')) def NR(x0): fx = int(x0**2 -3*x0 +1) fxp = 2*x0 - 3 f = x0 - fx/fxp f = x0 print('x:','\t','\t','\t',format(f,'.3f')) return '\t','\t','\t',x0 #print('\n','Spread sheet completed!') main()results:
x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 x: 0.375 Traceback (most recent call last): File "mathe project.py", line 25, in <module> main() File "mathe project.py", line 16, in main print(format(x0, '.3f')) TypeError: unsupported format string passed to tuple.__format__