Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42327

round off to two decimal & return float

Date 2013-03-30 13:22 +0530
From ஆமாச்சு <amachu@amachu.me>
Subject round off to two decimal & return float
Newsgroups comp.lang.python
Message-ID <mailman.3990.1364630137.2939.python-list@python.org> (permalink)

Show all headers | View raw


Consider the scenario,

>> a = 10
>> "{0:.2f}".format(a)
'10.00'

This returns a string 10.00. But what is the preferred method to retain
10.0 (float) as 10.00 (float)?

I am trying to assign the value to a cell of a spreadsheet, using
python-xlwt. I would like to have 10.00 as the value that is right
aligned. With text it is left aligned.

--

Sri Ramadoss M

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

round off to two decimal & return float ஆமாச்சு <amachu@amachu.me> - 2013-03-30 13:22 +0530
  Re: round off to two decimal & return float pyplexed <julius.welby@gmail.com> - 2013-03-30 02:30 -0700
  Re: round off to two decimal & return float pyplexed <julius.welby@gmail.com> - 2013-03-30 02:30 -0700

csiph-web