473,480 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

werid python troubles...

27 New Member
Hello,
I am just having a little trouble getting python to work correctly. When I try to divide 10 by 3 I get 3 instead of 3.3333 or when I do 1/3 i get 0.
Expand|Select|Wrap|Line Numbers
  1. >>> 10/3
  2. 3
  3. >>> 1/3
  4.  
  5.  
Any ideas as to what is causing this and how i can fix it??
Sep 24 '10 #1
1 1199
bvdet
2,851 Recognized Expert Moderator Specialist
You are seeing the results of integer division. Convert one of the numbers to float or import division from the __future__ module.
Expand|Select|Wrap|Line Numbers
  1. >>> 1/3
  2.  
  3. >>> from __future__ import division
  4. >>> 1/3
  5. 0.33333333333333331
  6. >>> float(1)/3
  7. 0.33333333333333331
  8. >>> 
Sep 24 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
2825
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon"...
2
2894
by: Dennis Hore | last post by:
I'm trying to install Nick Patavalis' ppgplot package on Mac OS X 10.3 with python 2.3. I first sent this message to Nick, but he said he doesn't have any experience with the Mac platform. ...
0
1942
by: lmckaha | last post by:
Hi, Mysql version: 3.23.49 Solaris version: 2.7 gcc compiler version: 2.95.2 Python : 2.2.2 I'm evaluating the C and C++ API to decide which one to bye but I have many troubles.
0
1211
by: Diez B. Roggisch | last post by:
QOTW: "In my view, the doctrinaire', indeed religious, adherence to OO purity has harmed our discipline considerably. Python was a nice breath of fresh air when I discovered it exactly because it...
0
1329
by: matt.keyes | last post by:
Hey all, i'm trying to create an application that both embeds and extends python through boost. i've got a rough framework up and running, but now that i'm finally to the python part i'm having...
5
1803
by: Falc | last post by:
Hi there... I have been looking at learning Python, so far it looks like an absolutely grat language. I am having trouble finding some free resources to learn Python from. I am on windows and...
7
1610
by: greg | last post by:
Thomas Philips wrote: Have a look in /Library/Frameworks/Python.framework/Versions/2.5 You can't -- this feature only exists in the Search window, which is a different kind of window...
0
7051
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7054
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7097
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6750
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
2993
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
567
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.