Eval function ...
suppose someone give you a task to evaluate a simple expression like 2+3 , 2*5, 3-4 , etc using python code . then you have to write the code for each arithmetic operator separately and if the expression contains more than 1 arithmetic operator and brackets also then using BODMAS rule also makes your code lengthy and complex also.In this situation eval function comes into role .
eval() :
How to use eval( ) in our code :
Syntax for eval function ..
- expression: this string is parsed and evaluated as a Python expression
- globals (optional): a dictionary to specify the available global methods and variables.
- locals (optional): another dictionary to specify the available local methods and variables.
So basically eval( ) function takes a string expression and returns the evaluate answer of integer type.
IS eval( ) is good for you code .
This blog is contributed by Yogesh singh
Admin of Instagram page dynamic_codeing
Output
A laptop (also laptop computer), often called a notebook, is a small, portable personal computer (PC) with a "clamshell" form factor, typically having a thin LCD or LED computer screen mounted on the inside of the upper lid of the clamshell and an alphanumeric keyboard on the inside of the lower lid. The clamshell is opened up to use the computer. Laptops are folded shut for transportation, and thus are suitable for mobile use. Its name comes from lap, as it was deemed to be placed on a person's lap when being used. Although originally there was a distinction between laptops and notebooks (the former being bigger and heavier than the latter), as of 2014, there is often no longer any difference. Today, laptops are commonly used in a variety of settings, such as at work, in education, for playing games, web browsing, for personal multimedia, and general home computer use.......
1 Comments
nice explaniation
ReplyDelete