I am trying to produce two columns of data in a table that also have a float output with 2 decimal places. I can do either or at the moment but not both. How can I simply combine the formats of these two?
#Code that shows 2 decimal places
def c2f():
print("Celsius","Fahrenheit")
for i in [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]:
c = i
f = 9 / 5 * i + 32
table_data = [
[c,f],
]
for row in table_data:
print("{: .2f} {: .2f}".format(*row))
c2f()
#Code that formats data into columns
def c2f():
print("Celsius","Fahrenheit")
for i in [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]:
c = i
f = 9 / 5 * i + 32
table_data = [
[c,f],
]
for row in table_data:
print("{: <20} {: <20}".format(*row))
c2f()