← coderbyte_practice

integer base 2

6b152ca1810e32af8653ee8bda29d9f79d0dc8eb · ovidiucs · May 8, 2015 11:20

+13 · 1 file changed

  • medium/09-BinaryConverter.py +13 −0
diff --git a/medium/09-BinaryConverter.py b/medium/09-BinaryConverter.py
new file mode 100644
index 0000000..a0f3f5a
--- /dev/null
+++ b/medium/09-BinaryConverter.py
@@ -0,0 +1,13 @@
+__author__ = 'ovidiucs'
+def BinaryConverter(str):
+
+    return int(str,2)
+
+
+
+# keep this function call here
+# to see how to enter arguments in Python scroll down
+print BinaryConverter("101")
+# Using the Python language, have the function BinaryConverter(str) return the
+# decimal form of the binary value. For example: if 101 is passed return 5, or if
+# 1000 is passed return 8.