programming logical functions: myand, myor and mynot

Gernot headroom02 at gmx.de
Thu Nov 15 01:28:47 CET 2001


Hi,

I want to implement the functions myand, myor and mynot. They should have
the same effect as the known boolean operators and, or and not.

The trick is that I am not allowed to use the boolean operators and, or and
not.

This is what I tried:
-----------
x = raw_input("Type something (x): ")
y = raw_input("Type something (y): ")

def myand(x,y):
    if bool(x) == 1:
        if bool(y) == 1:
         return 1
    return 0

if und(x,y) ==1:
    print "true"
else:
    print "false"
--------------

I think, the idea is not that wrong, but anyway, it doesn´t work! It has
something to do with "bool (x)", I think. Maybe this is something like a
module which i have to "activate" first??

Please give me some hints, I would be very grateful

Good Night

Gernot






More information about the Python-list mailing list