diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-12-17 21:31:23 +0000 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-12-17 21:31:23 +0000 |
| commit | df39e7263092169a4bf175cf328110b8151c39e8 (patch) | |
| tree | 752ca27ff2c81745c65f4b06b35fb6b2fa47caed /challenge-028/paulo-custodio/python | |
| parent | c12a27d57313357ebab130cfcff7ae9cf1c058d3 (diff) | |
| parent | 38ed50113d4c688df4e9d15a1a01342d7f5f651b (diff) | |
| download | perlweeklychallenge-club-df39e7263092169a4bf175cf328110b8151c39e8.tar.gz perlweeklychallenge-club-df39e7263092169a4bf175cf328110b8151c39e8.tar.bz2 perlweeklychallenge-club-df39e7263092169a4bf175cf328110b8151c39e8.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-028/paulo-custodio/python')
| -rw-r--r-- | challenge-028/paulo-custodio/python/ch-1.py | 17 | ||||
| -rw-r--r-- | challenge-028/paulo-custodio/python/ch-2.py | 89 |
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..3e796f3de5 --- /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) |
