Use of eval() in Python - Python eval function - int() vs eval() in Python - Python Programming

Publié le: 17 février 2022
sur la chaîne: Learn Computer
21,505
618

We always use int () in python to covert string to integer. like
x=int(input("Enter No 1:"))
y=int(input("Enter No 2:"))
z=x+y
print("Sum:",z)

we can use eval() also in place of int() like
x=eval(input("Enter No 1:"))
y=eval(input("Enter No 2:"))
z=x+y
print("Sum:",z)


in this video we clear the doubt students faces between int() vs eval(). Use of eval() in Python will make python code more versatile. Python eval function returns value which you want like integer , float, list, tuple etc. in Python Programming all must clear the use of eval(). in short if you want to read multiple values use eval function in python.

visit website :
https://anacondapython.com/


Sur cette page du site, vous pouvez voir la vidéo en ligne Use of eval() in Python - Python eval function - int() vs eval() in Python - Python Programming durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Learn Computer 17 février 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 21,505 fois et il a aimé 618 téléspectateurs. Bon visionnage!