•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 423,340 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,139 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 225 | Replies: 2
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
My 10 line calculator, I want it to display decimals when the equation calls for it.
#1
Jun 30th, 2008
python Syntax (Toggle Plain Text)
Y=1 N=0 cont=Y print "Welcome to SCLMIP(Simple Calculator For Linux Made In Python)" while cont == Y: equation=input("Equation: ") print equation cont=input("Continue? (Y,N)") else: print "Exiting..."
If you type 5/2 you get 2, I want it to display 2.5.
A workaround is typing 5.0/2.0, but it gets annoying. I want it to automatically decide to show decimals.
Re: My 10 line calculator, I want it to display decimals when the equation calls for it.
#2
Jul 1st, 2008
Re: My 10 line calculator, I want it to display decimals when the equation calls for it.
#3
Jul 1st, 2008
Starting with Python3 the / will be float division and // will be integer division. You can use these future feature already by importing the __future__ module:
python Syntax (Toggle Plain Text)
from __future__ import division print "Welcome to SCLMIP(Simple Calculator For Linux Made In Python)" while True: equation = input("Equation: ") print equation if raw_input("Continue? (Y,N)").upper() == 'N': break else: print "Exiting..."
drink her pretty
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Reload this Page problems making python program work with py2exe
- Next Thread: winsound SND_PURGE not working.



Linear Mode