{"id":24232,"date":"2021-10-14T09:18:53","date_gmt":"2021-10-14T03:48:53","guid":{"rendered":"https:\/\/python-programs.com\/?p=24232"},"modified":"2021-11-05T20:56:35","modified_gmt":"2021-11-05T15:26:35","slug":"python-program-for-exp-function","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-exp-function\/","title":{"rendered":"Python Program for exp() Function"},"content":{"rendered":"
In the previous article, we have discussed Python Program for modf() Function<\/a> The method math.exp() returns E raised to the power of x (Ex<\/sup>).<\/p>\n ‘E’ is the natural logarithmic system’s base (approximately 2.718282), and x is the number passed to it.<\/p>\n Syntax:<\/strong><\/p>\n Parameters:<\/strong><\/p>\n x:<\/strong> This is required. The exponent is specified by this.<\/p>\n Return Value:<\/strong><\/p>\n A float value representing ‘E’ raised to the power of x is returned as the return value.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Read all the mathematical functions available in Python and understand how to implement them in your program by using the tutorial of Python Mathematical Methods Examples<\/a>.<\/p>\n In the previous article, we have discussed Python Program for modf() Function exp() Function in Python: The method math.exp() returns E raised to the power of x (Ex). ‘E’ is the natural logarithmic system’s base (approximately 2.718282), and x is the number passed to it. Syntax: math.exp(x) Parameters: x: This is required. The exponent is …<\/p>\n
\nexp() Function in Python:<\/strong><\/p>\nmath.exp(x)<\/pre>\n
Given Number = 5<\/pre>\n
The result after applying exp() function on above given number 5 = 148.4131591025766<\/pre>\n
Given Number = 7.5<\/pre>\n
The result after applying exp() function on above given number 7.5 = 1808.0424144560632<\/pre>\n
Program for exp() Function in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the list as static input and store it in a variable.\r\ngvn_lst = [7, 4, 6, 14, 10]\r\n# Give the first number as static input and store it in another variable.\r\ngvn_numb1 = 5\r\n# Apply math.exp() function to the given first number to calculate the value\r\n# E raised to the power of given number.(E =approximately 2.718282)\r\n# Store it in another variable.\r\nfnl_rslt = math.exp(gvn_numb1)\r\nprint(\"The result after applying exp() function on above given first number\",\r\n gvn_numb1, \" = \", fnl_rslt)\r\n# similarly do the same for the other number.\r\ngvn_numb2 = 7.5\r\nprint(\"The result after applying exp() function on above given second number\",\r\n gvn_numb2, \" = \", math.exp(gvn_numb2))\r\n# Apply math.exp() function to the given list element and print it.\r\nprint(\r\n \"The result after applying exp() function on given list element gvnlst[1] = \", math.exp(gvn_lst[1]))\r\n<\/pre>\n
The result after applying exp() function on above given first number 5 = 148.4131591025766\r\nThe result after applying exp() function on above given second number 7.5 = 1808.0424144560632\r\nThe result after applying exp() function on given list element gvnlst[1] = 54.598150033144236<\/pre>\n
Method #2: Using Built-in Functions (User Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the list as user input using list(),map(),input(),and split() functions.\r\n# Store it in a variable.\r\ngvn_lst = list(map(float, input(\r\n 'Enter some random List Elements separated by spaces = ').split()))\r\n# Give the first number as user input using the float(input()) function\r\n# and store it in a variable.\r\ngvn_numb1 = float(input(\"Enter some random number = \"))\r\n# Apply math.exp() function to the given first number to calculate the value\r\n# E raised to the power of given number.(E =approximately 2.718282)\r\n# Store it in another variable.\r\nfnl_rslt = math.exp(gvn_numb1)\r\nprint(\"The result after applying exp() function on above given first number\",\r\n gvn_numb1, \" = \", fnl_rslt)\r\n# similarly do the same for the other number.\r\ngvn_numb2 = float(input(\"Enter some random number = \"))\r\nprint(\"The result after applying exp() function on above given second number\",\r\n gvn_numb2, \" = \", math.exp(gvn_numb2))\r\n# Apply math.exp() function to the given list element and print it.\r\nprint(\r\n \"The result after applying exp() function on given list element gvnlst[3] = \", math.exp(gvn_lst[3]))\r\n<\/pre>\n
Enter some random List Elements separated by spaces = 1 3 5 6 8\r\nEnter some random number = 3.5\r\nThe result after applying exp() function on above given first number 3.5 = 33.11545195869231\r\nEnter some random number = 9\r\nThe result after applying exp() function on above given second number 9.0 = 8103.083927575384\r\nThe result after applying exp() function on given list element gvnlst[3] = 403.4287934927351<\/pre>\n
\n