+ 1

How to give user input as 15.5+25.5-35.5 in python ?

10th Jun 2020, 11:00 AM
roja ch
roja ch - avatar
5 ответов
+ 6
If you want to calculate user's input... s = str(input()) #input 15.5+25.5-35.5 print(eval(s)) #output is 5.5
10th Jun 2020, 11:20 AM
Anton Popov
+ 3
Granger, BlueSky Yes, agree with you. My bad.
1st Jul 2020, 4:08 PM
Anton Popov
+ 1
Explain in better detail.
10th Jun 2020, 11:07 AM
Slick
Slick - avatar
+ 1
Thanks Anton Popov ...it is working fine
12th Jun 2020, 5:55 AM
roja ch
roja ch - avatar
+ 1
If you want to calculate user's input... s = str(input()) #input 15.5+25.5-35.5 print(eval(s)) #output is 5.5 Why use it str function. It is not necessary, because input return string?
1st Jul 2020, 3:28 PM
BlueSky