programming logical functions: myand, myor and mynot
jeff at ccvcorp.com
Thu Nov 15 21:47:45 CET 2001
> 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
> 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"
> 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.
More information about the Python-list