aboutsummaryrefslogtreecommitdiff
path: root/challenge-145/mohammad-anwar/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-145/mohammad-anwar/python')
-rw-r--r--challenge-145/mohammad-anwar/python/ch-1.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/challenge-145/mohammad-anwar/python/ch-1.py b/challenge-145/mohammad-anwar/python/ch-1.py
new file mode 100644
index 0000000000..de600fc0a5
--- /dev/null
+++ b/challenge-145/mohammad-anwar/python/ch-1.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python3
+
+'''
+
+Week 145:
+
+ https://theweeklychallenge.org/blog/perl-weekly-challenge-145
+
+Task #1: Dot Product
+
+ You are given 2 arrays of same size, @a and @b.
+
+ Write a script to implement Dot Product.
+
+'''
+
+import unittest
+
+def dot_product(a, b):
+
+ if len(a) == len(b):
+ dp = 0
+ for i in range(0, len(a)):
+ dp += a[i] * b[i]
+
+ return dp;
+
+#
+#
+# Unit test class
+
+class TestJortSort(unittest.TestCase):
+
+ def test_example(self):
+ self.assertEqual(
+ dot_product([1,2,3], [4,5,6]),
+ 32,
+ 'Example')
+
+unittest.main()