Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
""" The idea behind this code came from a user at a random irc channel asking how to find out if a number is even. The student expanded that the %-operator that was given in the exercise wasn't enough to solve the task so I coded this example for him. After coding for three hours I presented an initial solution to the student. Alas he didn't really grasp the code after which he thanked me for my efforts and left. Afterwards I added support for decimal numbers and negation for reasons I don't quite understand. Here is the execution of the module and code for your enjoyment purposes: tappi@virtual-debian:~$ python modulo.py True True True True True True """ from __future__ import division import re if negation: neg_str = " not" return self % divisor != 0 else: neg_str = " return self % divisor == 0 divisibleFunction.__doc__ = "Returns true if instance number is{1} divisible by {0}". divisibleFunction.__name__ = name try: return . except AttributeError: pass negation = True if else False result = if result is not None: divisor = return . result = if result is not None: whole_number = decimal_remainder = divisor = return . raise AttributeError return getattribute pass Int.__getattribute__ = pass Float.__getattribute__ = if __name__ == '__main__': i = print print print print f = print print |