eval() in python

 Composition in functions:

  • The composition function is used to execute expression and get an expression from the user.
  • Using eval() function and full form evaluate value through function. 
  • The value returned by a function may be used as an argument for another function in a nested manner. This is called composition.
  • For example, if we wish to take a numeric value or an expression as an input from the user, we take the input string from the user using the function input() and apply eval() function to evaluate its value.

Example program for print the set of elements:

  1. result=eval(input("Enter arithmetic operation: "))

    print(result)

Output:

Share:

No comments:

Post a Comment

Popular Posts

Search This Blog

Powered by Blogger.

Service Support

Need our help to Learn or Post New Concepts Contact me

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me