Python accepts a value and determines the type entered by the user with the help of eval() along with input() function.
If we are using only input() function, the type of variable entered by the user is always String.
age=input("Enter the age ")
print('age', age)
print(type(age))
Output:
Enter the age 45
age 45
class 'str'
If we are using eval() along with input() function, it automatically detects the type of variable entered by the user.
num=eval(input(("Enter the number ")))
print('num', num)
print(type(num))
Output:
Enter the number 67
num 67
class 'int'
#pythonprogramming #function #effortless #coding #developer #datatypesinpython #automation #pycharm
Sur cette page du site, vous pouvez voir la vidéo en ligne #python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Mastering Technology 23 décembre 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 61 fois et il a aimé 10 téléspectateurs. Bon visionnage!