July 22nd, 2004, 06:27 AM
Division error in python
I am first time here. Got just registered. I am learning the python programming...but there is a problem... when i divide a numerator with lower value than denominator i get value = 0 i.e.
it need complete value on division. how to obtain that?
I shall be thankful for the solution.
July 22nd, 2004, 06:35 AM
In the next release (Python 2.4 – coming soon!) you should get the right exact answer by default. Unfortunatly you're gonna have to wait for a month or two for this to get though the alpha and bete stages.
So, in the mean time, you can get do this by importing the feature from the __future__ module i.e.
Hope this helps,
July 22nd, 2004, 06:45 AM
if this module future is available..then no need to program itself boss. I think ti will have then everything to do....even an inbuilt command liner i.e. run program.py to run itself auto!
Any serious reply???
July 22nd, 2004, 07:03 AM
What?! The __future__ module holds features that will be added in the near "future". So if you have the latest version of Python (2.3) then division will be available. And, i would like to know what you mean by "Any serious reply"!!!
Originally Posted by BlueBaazigar
Dont want to use the future, then try dividing floats instead of ints.
July 22nd, 2004, 07:34 AM
Yep, if you want a floating point result you should use floating point numbers.
Last edited by Grim Archon; July 22nd, 2004 at 07:37 AM.
July 22nd, 2004, 08:18 AM
Thanks a lot to both of you. mark I am sorry...i really thought it was a joke...u see peculier module "__future__". I am impressed. Mark can you tell me best few books on python where i could get all these details. Right now i have wesley chun's core book and Mark Lutz's programming python. I really din't find description of future there!
Again thanks lot.
July 22nd, 2004, 10:59 AM
Not a problem. There's also __main__ and a __builtin__ modules too. Anyway you should check out "Learning Python, Second Edition" – a great book, for newbies and Pythonists alike.
Welcome to the forums,