Thats because you do integer division.

Do either:

float(15)/8
15/float(8)
15.0/8
15/8.0

Just be sure, that either 15 or 8 is a float, and not both an integer.

Best
Troels


2011/8/16 simulacrx <simula...@gmail.com>

>  hi;
> -----------------------
> check=(1,2,3,4,5,6,7,8,9,"/","*","-","+","(",")","[","]")
>
> while True:
>     a=raw_input("type your query : \n")
>     c=set(a).intersection(set(check))
>
>     if c:
>         print *eval("float(%s)"%a)*
>     else:
>         print "error! please use -defined operators-!"
> -----------------------------
>
> this script works.. but if i type
>
> 15/8
>
> it returns 1.. no floatin'.. i must fix this? can anyone help me?
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to