Using the AND and NOT Operator in Python

Posted by NoahClark on Stack Overflow See other posts from Stack Overflow or by NoahClark
Published on 2009-07-02T17:22:44Z Indexed on 2011/03/15 0:10 UTC
Read the original article Hit count: 226

Filed under:
|

Here is my custom class that I have that represents a triangle. I'm trying to write code that checks to see if self.a, self.b, and self.c are greater than 0, which would mean that I have Angle, Angle, Angle.

Below you will see the code that checks for A and B, however when I use just self.a != 0 then it works fine. I believe I'm not using & correctly. Any ideas? Here is how I am calling it: print myTri.detType()

class Triangle:

    # Angle A To Angle C Connects Side F
    # Angle C to Angle B Connects Side D
    # Angle B to Angle A Connects Side E

    def __init__(self, a, b, c, d, e, f):
    	self.a = a
    	self.b = b
    	self.c = c
    	self.d = d
    	self.e = e
    	self.f = f

    def detType(self):
    	#Triangle Type AAA
    	if self.a != 0 & self.b != 0:
    		return self.a

    	#If self.a > 10:
    		#return AAA

    	#Triangle Type AAS

    	#elif self.a = 0:
    		#return AAS

    	#Triangle Type ASA

    	#Triangle Type SAS

    	#Triangle Type SSS	

    	#else:
    		#return unknown

© Stack Overflow or respective owner

Related posts about python

Related posts about operators