0

I have a problem with my code. I use "eval()" and the problem is that I have a lot of resultat like it :

7*1*6*10-9+3 => 414 7*1*6*10-9-3 => 408 7*1*6*10-9*3 => 393 7*1*6*10-9/3 => 417.0 7*1*6*10/9*3 => 140.0 7*1*6/10*9*3 => 113.4 7*1/6+10*9*3 => 271.1666666666667 7*1/6*10*9+3 => 108.00000000000001 7*1/6*10*9-3 => 102.00000000000001 7*1/6*10*9*3 => 315.00000000000006 7/1+6+10*9+3 => 106.0 7/1+6+10*9*3 => 283.0 7/1+6*10*9+3 => 550.0 7/1+6*10*9-3 => 544.0 

My code to get the result is

eval(operation), like eval('7*1*6*10-9+3') etc 

I would like not display the decimal number like 33,33 or 102,000001. But I would like display 106.0 without the ",0" just like it : "106"

Thanks for reading me !!

3
  • 1
    I cited one of many possible references for output formatting. I suggest you look up the Python documentation so you solve all of your upcoming formatting questions. Commented Apr 9, 2020 at 19:53
  • It's not same thing Commented Apr 9, 2020 at 19:56
  • 1
    No, but it leads you directly to the formatting issues you need to choose. Your question isn't quite clear enough, specifying only one output example. Learn the d, gm and f formats to cover any of the possible interpretations. Commented Apr 9, 2020 at 20:02

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.