File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,23 +11,3 @@ tex2pdf*
1111.coverage
1212.idea
1313.vscode
14- 02_crowsnest /crowsnest.py
15- 03_picnic /picnic.py
16- 04_jump_the_five /jump.py
17- 05_howler /howler.py
18- 06_wc /wc.py
19- 07_gashlycrumb /gashlycrumb.py
20- 08_apples_and_bananas /apples.py
21- 09_abuse /abuse.py
22- 10_telephone /telephone.py
23- 11_bottles_of_beer /bottles.py
24- 12_ransom /ransom.py
25- 13_twelve_days /twelve_days.py
26- 14_rhymer /rhymer.py
27- 15_kentucky_friar /friar.py
28- 16_scrambler /scrambler.py
29- 17_mad_libs /mad.py
30- 18_gematria /gematria.py
31- 19_wod /wod.py
32- 20_password /password.py
33- 21_tictactoe /tictactoe.py
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ """
3+ Author : Johan Runesson <info@johanrunesson.se>
4+ Date : 2020-08-03
5+ Purpose: Crow\' s Nest -- choose the correct article
6+ """
7+
8+ import argparse
9+
10+
11+ # --------------------------------------------------
12+ def get_args ():
13+ """Get command-line arguments"""
14+
15+ parser = argparse .ArgumentParser (
16+ description = 'Crow\' s Nest -- choose the correct article' ,
17+ formatter_class = argparse .ArgumentDefaultsHelpFormatter )
18+
19+ parser .add_argument ('word' , metavar = 'word' , help = 'A word' )
20+
21+ return parser .parse_args ()
22+
23+
24+ # --------------------------------------------------
25+ def main ():
26+ """Start things up"""
27+
28+ args = get_args ()
29+ word = args .word
30+ article = 'an' if word [0 ].lower () in 'aeiou' else 'a'
31+
32+ print (f'Ahoy, Captain, { article } { word } off the larboard bow!' )
33+
34+
35+ # --------------------------------------------------
36+ if __name__ == '__main__' :
37+ main ()
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ """
3+ Author : Johan Runesson <info@johanrunesson.se>
4+ Date : 2020-08-03
5+ Purpose: Jump the Five
6+ """
7+
8+ import argparse
9+
10+
11+ # --------------------------------------------------
12+ def get_args ():
13+ """Get command-line arguments"""
14+
15+ parser = argparse .ArgumentParser (
16+ description = 'Jump the Five' ,
17+ formatter_class = argparse .ArgumentDefaultsHelpFormatter )
18+
19+ parser .add_argument ('number' , metavar = 'str' , help = 'A number' )
20+
21+ return parser .parse_args ()
22+
23+
24+ # --------------------------------------------------
25+ def main ():
26+ """Start things up"""
27+
28+ args = get_args ()
29+ number = args .number
30+
31+ jumper = {
32+ '1' : '9' ,
33+ '2' : '8' ,
34+ '3' : '7' ,
35+ '4' : '6' ,
36+ '5' : '0' ,
37+ '6' : '4' ,
38+ '7' : '3' ,
39+ '8' : '2' ,
40+ '9' : '1' ,
41+ '0' : '5'
42+ }
43+
44+ for char in number :
45+ print (jumper .get (char , char ), end = '' )
46+ print () # To get rid of the %-character at the end (not sure why it gets printed)
47+
48+ # print(number.translate(number.maketrans(jumper)))
49+
50+
51+ # --------------------------------------------------
52+ if __name__ == '__main__' :
53+ main ()
You can’t perform that action at this time.
0 commit comments