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.

Recommended Answers

All 2 Replies

I know this doesn't answer the question, but
Could you just use True and False keywords instead of Y and N?

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:

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..."
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.