from IPython.display import *
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?
for ts in range(4):
sol = solve((c + p + ts - 20,c * 2 + p * 4 + ts * 8 - 56),(c,p)) \
or {c:None,p:None}
sol[s] = ts
display(sol)