Behavior of exec function in Python 2 and Python 3
Behavior of exec function in Python 2 and Python 3 Question: Following code gives different output in Python2 and in Python3: from sys import version print(version) def execute(a, st): b = 42 exec(“b = {}nprint(‘b:’, b)”.format(st)) print(b) a = 1. execute(a, “1.E6*a”) Python2 prints: 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] …