diff options
| author | Conor Hoekstra <codereport@outlook.com> | 2021-12-24 22:16:15 -0500 |
|---|---|---|
| committer | Conor Hoekstra <codereport@outlook.com> | 2021-12-24 22:16:15 -0500 |
| commit | c804b128cf740d95b244cd3fe15e86d0820ab51e (patch) | |
| tree | b9db7c3a5f93e6a83640f56bfd5decb9bbe8dbfe /challenge-028/paulo-custodio/python | |
| parent | 116add27d0d74360c7d4ad26b12d972657e51afa (diff) | |
| parent | 6f518c687f743b68d3eeddedcf3d831aca20d4ec (diff) | |
| download | perlweeklychallenge-club-c804b128cf740d95b244cd3fe15e86d0820ab51e.tar.gz perlweeklychallenge-club-c804b128cf740d95b244cd3fe15e86d0820ab51e.tar.bz2 perlweeklychallenge-club-c804b128cf740d95b244cd3fe15e86d0820ab51e.zip | |
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
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) |
