equivalent of NULL or OM in Python

cyberian bear cyberian_bear at hotmail.com
Fri Feb 16 03:37:43 EST 2001


1.I'm doing a program in Python which perform +, -, *, / on two polynomials.
Their coefficient and exponentials are stored in tuples. So for example
3X^2+4X+4 would be stored like [(2,3),(1,4),(0,4)] but what if the term is
absent completely from one of the polynomials then i would have to check if
one of the tuuples is not present at all and not just zero. For  example
[(2,3),(0,4)]. In Pascal there is NULL in SETL there is OM but is there a
corresponding statement in Python. I've checked through several sources
including my textbook but didn't find the satisfactory answer. Maybe I
should just check if the second term of every tuple(i.e the coefficient) is
zero which means that the term is not present.
2. Also can anyone give me a clue how to iterate over all the coefficient
terms in the tuples in the first polynomials' tuples.
My guess is should be something like
for coefficient in polynomial1:
where polynomial is a list of tuples
but how do i tell it to iterate specifically over the second term in every
tuple and not over the whole tuples
cb





More information about the Python-list mailing list