Functions using libraries
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 a input from the user, we take the
input string from the user using the function input() and apply eval()
function to evaluate its value, for example:
Example :
This program
explains composition
>>>n1 = eval (input
("Enter a number: "))
Enter a number: 234
>>>n1
234
>>>n2 = eval (input
("Enter an arithmetic expression: "))
Enter an arithmetic expression:
12.0+13.0 * 2
>>> n2
38.0
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.