aboutsummaryrefslogtreecommitdiff
path: root/challenge-028/paulo-custodio/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-028/paulo-custodio/python')
-rw-r--r--challenge-028/paulo-custodio/python/ch-1.py17
-rw-r--r--challenge-028/paulo-custodio/python/ch-2.py89
2 files changed, 106 insertions, 0 deletions
diff --git a/challenge-028/paulo-custodio/python/ch-1.py b/challenge-028/paulo-custodio/python/ch-1.py
new file mode 100644
index 0000000000..2ed8ff5b7b
--- /dev/null
+++ b/challenge-028/paulo-custodio/python/ch-1.py
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+
+# Challenge 028
+
+# Task #1
+# Write a script to check the file content without explicitly reading the
+# content. It should accept file name with path as command line argument and
+# print "The file content is binary." or else "The file content is ascii."
+# accordingly.
+
+import sys
+
+file = sys.argv[1]
+if b'\x00' in open(file, 'rb').read():
+ print("The file content is binary.")
+else:
+ print("The file content is ascii.")
diff --git a/challenge-028/paulo-custodio/python/ch-2.py b/challenge-028/paulo-custodio/python/ch-2.py
new file mode 100644
index 0000000000..51771c3ad9
--- /dev/null
+++ b/challenge-028/paulo-custodio/python/ch-2.py
@@ -0,0 +1,89 @@
+#!/usr/bin/python3
+
+# Challenge 028
+
+# Task #2
+# Write a script to display Digital Clock. Feel free to be as creative as you
+# can when displaying digits. We expect bare minimum something like "14:10:11".
+
+from datetime import datetime
+import time
+
+chars = {
+ ' ': [" ",
+ " ",
+ " ",
+ " ",
+ " "],
+ '0': [" ___ ",
+ " | |",
+ " | |",
+ " | |",
+ " |___|"],
+ '1': [" ",
+ " |",
+ " |",
+ " |",
+ " |"],
+ '2': [" ___ ",
+ " |",
+ " ___|",
+ " | ",
+ " |___ "],
+ '3': [" ___ ",
+ " |",
+ " ___|",
+ " |",
+ " ___|"],
+ '4': [" ",
+ " | |",
+ " |___|",
+ " |",
+ " |"],
+ '5': [" ___ ",
+ " | ",
+ " |___ ",
+ " |",
+ " ___|"],
+ '6': [" ___ ",
+ " | ",
+ " |___ ",
+ " | |",
+ " |___|"],
+ '7': [" ___ ",
+ " | |",
+ " | |",
+ " |",
+ " |"],
+ '8': [" ___ ",
+ " | |",
+ " |___|",
+ " | |",
+ " |___|"],
+ '9': [" ___ ",
+ " | |",
+ " |___|",
+ " |",
+ " ___|"],
+ ':': [" ",
+ " ",
+ " . ",
+ " . ",
+ " "],
+}
+
+CLEAR = "\x1b[H\x1b[2J"
+HOME = "\x1b[H"
+
+def banner(text):
+ for row in range(len(chars[' '])):
+ for c in text:
+ print(chars[c][row], end="")
+ print("")
+
+print(CLEAR, end="")
+while True:
+ now = datetime.now()
+ print(HOME, end="")
+ banner(now.strftime("%H:%M:%S"))
+ time.sleep(0.5)