aboutsummaryrefslogtreecommitdiff
path: root/challenge-112/roger-bell-west/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-05-10 12:27:21 +0100
committerGitHub <noreply@github.com>2021-05-10 12:27:21 +0100
commitce8ea1ef30f04a000ce2e37479deeffe62ee19ac (patch)
tree54e8a1c7f9bd30fee3e4397b70a7569e727951e2 /challenge-112/roger-bell-west/python/ch-2.py
parent76c9c09c0b2deac8a801ad60f866cdcdb97caa8c (diff)
parent1304dad6c048c415507ecd8484dc4bc8791457e8 (diff)
downloadperlweeklychallenge-club-ce8ea1ef30f04a000ce2e37479deeffe62ee19ac.tar.gz
perlweeklychallenge-club-ce8ea1ef30f04a000ce2e37479deeffe62ee19ac.tar.bz2
perlweeklychallenge-club-ce8ea1ef30f04a000ce2e37479deeffe62ee19ac.zip
Merge pull request #4052 from Firedrake/rogerbw-challenge-112
Solutions for challenge #112
Diffstat (limited to 'challenge-112/roger-bell-west/python/ch-2.py')
-rwxr-xr-xchallenge-112/roger-bell-west/python/ch-2.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-112/roger-bell-west/python/ch-2.py b/challenge-112/roger-bell-west/python/ch-2.py
new file mode 100755
index 0000000000..77dcdbca19
--- /dev/null
+++ b/challenge-112/roger-bell-west/python/ch-2.py
@@ -0,0 +1,26 @@
+#! /usr/bin/python3
+
+import unittest
+
+def cs(i):
+ a=0
+ b=1
+ c=0
+ for x in range(i):
+ c=a+b
+ a=b
+ b=c
+ return c
+
+class TestCs(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(cs(3),3,'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(cs(4),5,'example 2')
+
+ def test_ex3(self):
+ self.assertEqual(cs(20),10946,'example 3')
+
+unittest.main()