[Tutor] 42

Christoph Karner relative at unimx.de
Fri Jun 11 12:38:58 EDT 2004


> print "What do you get if you multiply six by nine: %d" % 6 * 7
Okay, that's quite clear :-)

Multiplying 6 with 9 to get 42 is rather a joke than
programming...seehttp://en.wikipedia.org/wiki/The_Answer_to_Life%2C_the_Universe%2C_and_Everything for details.

> I don't think Python can duplicate this specific bug (yes, of course
> it's a bug) from C, at least not without using a C extension. I think
> that's probably a good thing.
I don't think that this is a bug, it's rather an advised error in
reason.

#define SIX (1 + 5)
#define NINE (8 + 1)

This works as Adam Riese would appreciate. If you leave the brackets,
your computer calculates 1 + 5 * 8 + 1, and this is 42.

Christoph




More information about the Tutor mailing list