GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Python/maths/abs.py at master · dwsandy30/Python Expand file tree/ Copy pathabs.pyMore file actions 28 lines (21 loc) · 464 Bytes / Copy pathabs.pyFile metadata and controls28 lines (21 loc) · 464 Bytes 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 """Absolute Value.""" def abs_val(num): """ Find the absolute value of a number. >>> abs_val(-5.1) 5.1 >>> abs_val(-5) == abs_val(5) True >>> abs_val(0) 0 """ return -num if num < 0 else num def test_abs_val(): """ >>> test_abs_val() """ assert 0 == abs_val(0) assert 34 == abs_val(34) assert 100000000000 == abs_val(-100000000000) if __name__ == "__main__": print(abs_val(-34)) # --> 34 |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |