|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Division error in python
Hi All!
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. >x=2/3 >print x >0 it need complete value on division. how to obtain that? I shall be thankful for the solution. |
|
#2
|
||||
|
||||
|
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. Quote:
Hope this helps, Mark. |
|
#3
|
|||
|
|||
|
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??? |
|
#4
|
||||
|
||||
|
Quote:
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"!!! Dont want to use the future, then try dividing floats instead of ints. Code:
>>> 2.0/3.0 0.66666666666666663 >>> Mark. |
|
#5
|
||||
|
||||
|
Yep, if you want a floating point result you should use floating point numbers.
__________________
*** Experimental Python Markup CGI V2 *** Last edited by Grim Archon : July 22nd, 2004 at 07:37 AM. |
|
#6
|
|||
|
|||
|
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. |
|
#7
|
||||
|
||||
|
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, Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Division error in python |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|