In python ; instead of using the #float and #int functions after reading a numeric value, can the #eval function be used ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

In python ; instead of using the #float and #int functions after reading a numeric value, can the #eval function be used ?

Eval

3rd May 2019, 9:36 PM
Abdelkader Barraj عبد القادر البراج
Abdelkader Barraj عبد القادر البراج - avatar
4 Answers
+ 6
Just tried it and yes, it works! https://code.sololearn.com/cbs0fyO9Xq2d/?ref=app
3rd May 2019, 10:44 PM
Edwin Pratt
Edwin Pratt - avatar
+ 5
Hey there, Please add more details and what language you are using so that I can give a better answer _____ Eval is not actually recommended, but it should be possible.
3rd May 2019, 10:21 PM
Edwin Pratt
Edwin Pratt - avatar
+ 5
Edwin Pratt Thank you
3rd May 2019, 10:46 PM
Abdelkader Barraj عبد القادر البراج
Abdelkader Barraj عبد القادر البراج - avatar
+ 4
Edwin Pratt In python ; instead of using the #float and #int functions after reading a numeric value, can the #eval function be used? Is it more suitable for reading? because float and int are reserved for type conversion. Exemple: nb = eval (input ("enter a number:"))
3rd May 2019, 10:34 PM
Abdelkader Barraj عبد القادر البراج
Abdelkader Barraj عبد القادر البراج - avatar