python eval() code example
Example 1: python zfill
num = "7"
print(num.zfill(2))
Example 2: python log10
import math
math.log10( x )
Example 3: python eval function
x = 100
y = 200
eval('6 * 7')
eval('x + y')
eval('x + y',{'x':50,'y':25})
'''eval accepts the following expression examples:
literals : 6 and 7 from above are literals also lists, floats, boolean,strings
names : my_num = 3 # the my_num is the name :NOTE that assignments are not allowed in eval
attributes: funtion_name.attribute
operations: * from above is an operator
functions: must return a value eval( sum( [8,16,32] ) ) gives: 56, fibonacci(3)
'''
Example 4: eval in python
eval(expression, [globals[, locals]])
Example 5: np.vstack python
import numpy as np
a = np.array([1, 2, 3])
b = np.array([2, 3, 4])
np.vstack((a,b))