In this python function program, we will execute a string containing Python code.
String: A string is any series of characters that are interpreted literally by a script. For example, “Python”.
What is Function?
It is a block of code that executes when it is called.
To create a function use def keyword.
Steps to solve the program
mycode = 'print("Python")'
code = """
def mutiply(x,y):
return x*y
print('sqatools')
"""
exec(mycode)
exec(code)
Output :
Python
sqatools
Related Articles
Python function program to access a function inside a function.
Python function program to find the LCM of two numbers.
Python function program to calculate the sum of numbers from 0 to 10.
Python function program to find the HCF of two numbers.
Python function program to create a function with *args as parameters.
Python function program to get the factorial of a given number.