What will be the output of the following Python functions?
x=3
eval('x^2')
x=3
eval('x^2')A. Error
B. 1
C. 9
D. 6
Answer: Option B
Solution (By Examveda Team)
Theeval() function in Python evaluates the specified expression, which is a string, and returns the result. In this case, the expression 'x^2' is evaluated. However, the ^ operator in Python represents bitwise XOR, not exponentiation. So, 'x^2' evaluates to 3⊕2=6 in bitwise XOR. Therefore, the output of the function call eval('x^2') will be 6. 
Join The Discussion