| Reply | « Previous Thread | Next Thread » |
|
hi everybody,
sometimes i was using python's interactive console as a calculator but it's not calculating rational numbers like 1/2 ,3/4 it's answering with 0 when i make a calculation that includes rational numbers? my question is can i calculate rational numbers in python 1.4.5?and how to? pls help! sorry for my english. |
| McLightning |
| View Public Profile |
| Find all posts by McLightning |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
Hi,
x/y by default returns the quotient. For example, 16/5 returns 3 because 16=3*5+1. Just write one of the numbers as a float and it will work. 16.0/5 returns 3.2 You can also use this: Code:
>>> from __future__ import division >>> 11/4 2.75 |
|
thanks for help. i got it now.
Last edited by McLightning : 2009-03-08 at 19:14.
|
| McLightning |
| View Public Profile |
| Find all posts by McLightning |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Interactive console | BAM8 | Python | 3 | 2008-10-27 11:27 |
| Wlan interactive console | mlinden | Python | 1 | 2008-10-20 05:03 |
| Sensor API within console application | Saxer | General Symbian C++ | 3 | 2008-07-16 14:38 |
| Can't kill process when console is enabled | alav | General Symbian C++ | 3 | 2007-11-28 20:07 |
| input function in interactive console | d.nieto | Python | 3 | 2006-11-11 11:40 |