+ 3

What does eval function do in python?

26th Dec 2018, 11:57 AM
shreyash joshi
shreyash joshi - avatar
7 Respostas
+ 5
it returns eval("2*3*4")
26th Dec 2018, 12:17 PM
ShortCode
+ 4
It does something similar to what interpreter do. It executes the given statement inside the method.
26th Dec 2018, 12:46 PM
Seniru
Seniru - avatar
+ 3
shreyash joshi in your code e variable is the string type .you can check it by like print(e) or print(type(e)) and eval just executing it.go line by line you can easily understand it.
26th Dec 2018, 4:11 PM
Maninder $ingh
Maninder $ingh - avatar
+ 2
evaluate what is the result of the string
26th Dec 2018, 12:02 PM
ShortCode
+ 2
"3+3" -> 6
26th Dec 2018, 12:02 PM
ShortCode
+ 2
Then what does this code do? def f(r): j=range(r) e=eval("*".join([str(i+2)for i in j])) return e print(f(3))
26th Dec 2018, 12:10 PM
shreyash joshi
shreyash joshi - avatar
0
deserialize ur code
27th Dec 2018, 5:44 PM
new learner