[Tutor] Division operation
Miguel Estrada
archangel at interbaun.com
Tue May 16 21:40:08 CEST 2006
Hi there,
I'm new to Python and programming in general.
This is the function I am writing:
def function():
x = int(raw_input("Enter value of x: "))
y = int(raw_input("Enter value of y: "))
z = x / y
print "The value of z is", z, "unit of measurement"
Now, say, user input:
x = 200
y = 1000
The value returned will be '0'.
My question: What is the proper way of writing the operation so that if
z = x /y, the result would be '0.20' instead of just '0'?
TIA.
-Miguel
More information about the Tutor
mailing list