Подскажите как форматировано вывести элементы массивов в 6 столбиков, с точностью двух цифр после запятой, по аналогии как получается с командой
print '%.2f %.2f %2.f %.2f %.2f %2.f %2.f %2.f\n' % (x, fx, fd, cd, bd, fd2, cd2, bd2
Самому удалось найти только как вывести первый массив в столбик без нужной мне точности.
from math import sin
def f(x):
return sin(3*x)+sin(2*x)+sin(x)
h=0.01
x=3
k=3
fx=f(x)
a = []
for i in range(100):
x=x+h
fx=f(x)
fd=(f(x+h)-f(x))/h
fd2=(f(x+2*h)-2*f(x+h)+f(x))/h**2
bd=(f(x)-f(x-h))/h
bd2=(f(x)-2*f(x-h)+f(x-2*h))/h**2
cd=(f(x+h)-f(x-h))/(2*h)
cd2=(f(x+h)-2*f(x)+f(x-h))/h**2
a.append(fd)
print 'stolbik1'
print '\n'.join([str(entry) for (n, entry) in zip(range(0,len(a)), a)])
# print '%.2f %.2f %2.f %.2f %.2f %2.f %2.f %2.f\n' % (x, fx, fd, cd, bd, fd2, cd2, bd2)