programming logical functions: myand, myor and mynot
Jeff Shannon
jeff at ccvcorp.com
Thu Nov 15 15:47:45 EST 2001
Gernot wrote:
> 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??
There is no bool() in Python. You'll have to build your own. But at least
you've got a decent start on your homework.
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list