Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Substitute and evaluate

Hello, I would like to ask a really easy question:

How can I substitute a variable into an equation and have it evaluated simultaneously? If I have $f = a + b$ and would it to return $5$ if $a=2$ and $b=3$, how shall I proceed?

I've tried the following

a, b = var('a, b');
f = a + b;
a = 2; b = 3; f

But it returned a+b, which is not what I had in mind. Thanks for the help in advance!