+ 1

How to input a function ?

I want input a function. Example: >> Enter f (x): (x**2) + 1 >> enter interval separeted by comma: 0,1 >> Insert the number of n: 10 #This code will calculate an integral from 0 to 1 of x^2 + 1, separating this interval in 10 equal parts, using the Simpsons method. But I don't know how to input a function an use it inside my code. Could someone help me ? Thanks for your attention.

28th Jul 2018, 11:02 PM
▲TopGun ▲
▲TopGun ▲ - avatar
1 Odpowiedź
0
use built-in eval() and exec() function refer py doc for more info
29th Jul 2018, 5:07 AM
ĐɆⱤɆJɆ the₲reat
ĐɆⱤɆJɆ the₲reat - avatar