In [4]:
from sympy import *
var('c p s', integer = True, positive = True)
# There are 20 heads and 56 legs. How many chickens,
# pigs and spiders are there?
solve((c + p + s - 20,c * 2 + p * 4 + s * 8 - 56),(c,p,s))
Out[4]:
{c: 2*s + 12, p: -3*s + 8}