programming-examples/python/Function/Python program to execute a string containing Python code.py

9 lines
172 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
mycode = 'print("hello world")'
code = """
def mutiply(x,y):
return x*y
print('Multiply of 2 and 3 is: ',mutiply(2,3))
"""
exec(mycode)
exec(code)