[Tutor] Format strings for variables - how?

Viktor Lakics lakicsv@usa.net
Thu, 8 Feb 2001 07:10:02 +0000


Hi dear Tutors,

Sorry for the basic question, I am just a starter in Python...

a=1
b=3
print "%0.2f" %(a/b)

The above code gives me 0.00 as a result, while I wanted to get
0.33...

Interestingly enough, if use

print "%0.2f" %(0.3333333)

I get 0.33 as a result...

Can someone explain this to me?
What should I use in the example with the variables to get the
display format what I want?

Viktor