from z3 import * square = Int("square") circle = Int("circle") triangle = Int("triangle") solver = Solver() solver.add(square * square + circle == 16) solver.add(triangle * triangle * triangle == 27) solver.add(triangle * square == 6) # sat stands for sastisfiable, meaning that the set of constraints are satisfiable if solver.check() == sat: m = solver.model() # eval method returns the numbers with the type z3.z3.IntNumRef # as_long method is used to convert that type to int square_value = m.eval(square).as_long() circle_value = m.eval(circle).as_long() triangle_value = m.eval(triangle).as_long() result = square_value * circle_value * triangle_value print("The answer is: ", result)