diff options
| author | Steven <steven1170@zoho.eu> | 2024-01-29 21:47:46 +0000 |
|---|---|---|
| committer | Steven <steven1170@zoho.eu> | 2024-01-29 21:47:46 +0000 |
| commit | d63377644b6fe7841a4e25eace5190494d2107cf (patch) | |
| tree | 1ad4c2069ff4d153325dd07e1c7308392dca4c82 /challenge-254/steven-wilson/python/ch-01.py | |
| parent | 4099837cf3689e1d78a66905fde9c5a45ff95940 (diff) | |
| download | perlweeklychallenge-club-d63377644b6fe7841a4e25eace5190494d2107cf.tar.gz perlweeklychallenge-club-d63377644b6fe7841a4e25eace5190494d2107cf.tar.bz2 perlweeklychallenge-club-d63377644b6fe7841a4e25eace5190494d2107cf.zip | |
add solutions week 254 in python
Diffstat (limited to 'challenge-254/steven-wilson/python/ch-01.py')
| -rw-r--r-- | challenge-254/steven-wilson/python/ch-01.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-254/steven-wilson/python/ch-01.py b/challenge-254/steven-wilson/python/ch-01.py new file mode 100644 index 0000000000..6c51d189e2 --- /dev/null +++ b/challenge-254/steven-wilson/python/ch-01.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +import math + + +def is_power_three(number): + ''' Given a positive integer. Returns true if the given integer is a power + of three otherwise returns false. + + >>> is_power_three(27) + True + >>> is_power_three(0) + True + >>> is_power_three(6) + False + ''' + cr = round(math.pow(number, 1/3), 6) + return ((cr - int(cr)) == 0) + + +if __name__ == "__main__": + import doctest + + doctest.testmod() |
