<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: D Smith</title>
    <description>The latest articles on DEV Community by D Smith (@zeeter).</description>
    <link>https://dev.to/zeeter</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F6108%2Fc457df43-4d74-4558-9dd1-95cdf74e1782.jpg</url>
      <title>DEV Community: D Smith</title>
      <link>https://dev.to/zeeter</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zeeter"/>
    <language>en</language>
    <item>
      <title>Stuff I'm Working on</title>
      <dc:creator>D Smith</dc:creator>
      <pubDate>Sun, 28 Apr 2019 19:28:59 +0000</pubDate>
      <link>https://dev.to/zeeter/stuff-i-m-working-on-541g</link>
      <guid>https://dev.to/zeeter/stuff-i-m-working-on-541g</guid>
      <description>&lt;p&gt;Howdy everyone. I noticed that I got a few more followers in the last little bit despite never writing. My hope is that you've been my last few articles. I've been planning to write a few more but I don't usually have time because of work and school.&lt;/p&gt;

&lt;p&gt;That being said, I have a few ideas planned out:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;My attempts at challenges from /r/dailyprogrammer&lt;/li&gt;
&lt;li&gt;A neat little side project on literate openscad for 3d printing.&lt;/li&gt;
&lt;li&gt;Some neat math ideas that I'm working on.&lt;/li&gt;
&lt;li&gt;Refining my note style.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As with all of my work, none of these ideas are inherently practical. But I don't do practical. If any of those gists sound interesting to you. Please leave a comment and I'll see about putting them higher in my priority list. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Piglatin in python and orgmode.</title>
      <dc:creator>D Smith</dc:creator>
      <pubDate>Mon, 10 Dec 2018 17:28:44 +0000</pubDate>
      <link>https://dev.to/zeeter/piglatin-in-python-and-orgmode-2k69</link>
      <guid>https://dev.to/zeeter/piglatin-in-python-and-orgmode-2k69</guid>
      <description>

&lt;h1&gt;
  
  
  Table of Contents
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt; Concept
&lt;/li&gt;
&lt;li&gt; Finding vowels
&lt;/li&gt;
&lt;li&gt; Stripping the first letter
&lt;/li&gt;
&lt;li&gt; Putting it together
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a id="org835aead"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Concept
&lt;/h1&gt;

&lt;p&gt;The Pig Latin translator is a program that takes a string and transforms it by&lt;br&gt;
moving the first letter to the last and adding "ay" onto it.&lt;br&gt;
However if the letter would be a vowel, the entire process is replaced with "way"&lt;br&gt;
so:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dog
Nyx
Puppy
Gizmo
Kitten
Luna-fish
Tuna-fish
Apple
Orange
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Would become:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ogday
Yxna
Uppypay
Izmogay
Ittenkay
Una-fishlay
Una-fishtay
Ppleway
Rangeway
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I'm sure that implimenting full sentences are possible, but that does fall out of the scope of the&lt;br&gt;
challenge so we will not be doing those for the time being.&lt;/p&gt;

&lt;p&gt;&lt;a id="org03ef308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Finding vowels
&lt;/h1&gt;

&lt;p&gt;To find the vowels we simply need them in a nice and handy location.&lt;br&gt;
In this case as a string.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vowels = "aeiou"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;then we can simply check if the input string is infact a vowel by seeing if its in the string.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isVowel(letter):

    vowels = "aeiou"
    return letter in vowels
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Lets see if it worked!&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isVowel(letter):

    vowels = "aeiou"
    return letter in vowels
con = isVowel(letter.lower())

if con:
    return "{} is a vowel".format(letter.lower())
else:
    return "{} is not a vowel".format(letter.lower())
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;  a is a vowel&lt;/li&gt;
&lt;li&gt;  b is not a vowel&lt;/li&gt;
&lt;li&gt;  abc is not a vowel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But to be good, lets actually make a docstring describing what this "function" does.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Checks to see if a letter is a vowel.
for example:
&amp;gt;&amp;gt;&amp;gt; isVowel("a")
True
&amp;gt;&amp;gt;&amp;gt; isVowel("b")
False
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;However as written, it wont take captial letters. But this is intended. to avoid weirdness with&lt;br&gt;
casing, I'm turning everything into lowercase letters. so crisis averted for now.&lt;/p&gt;

&lt;p&gt;&lt;a id="org7878e91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Stripping the first letter
&lt;/h1&gt;

&lt;p&gt;Now we can check vowels, but so what?&lt;br&gt;
Well now we start actually possessing our word.&lt;br&gt;
For this, we really don't need a function. But writing in orgmode's makes the notion of&lt;br&gt;
code blocks as functions seem so easy.&lt;br&gt;
It also makes testing each code block easier, so python can bite me on this one.&lt;br&gt;
They aren't venomous snakes after all.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def stripFirst(word):

    first = word[0]
    rest = word[1:]

    return (first, rest)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And now time for our docstring:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Strip first takes a word and returns two strings.
One consisting of just the first letter and then the rest of the word.
Example:
&amp;gt;&amp;gt;&amp;gt; stripFirst("Daniel")
("D","aniel")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a id="orgdcf180d"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Putting it together
&lt;/h1&gt;

&lt;p&gt;So I could further break the code down, but there wouldn't atleast in my opinion&lt;br&gt;
be much value gained from that. Instead, I'm going to jump ahead a few steps and assemble the piglatin function.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isVowel(letter):

    vowels = "aeiou"
    return letter in vowels
def stripFirst(word):

    first = word[0]
    rest = word[1:]

    return (first, rest)

def pigLatin(word):
    first, rest = stripFirst(word.lower())

    if isVowel(first):
    return rest + "way"
    else:
    return rest + first + "ay"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Technically, we're done. &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isVowel(letter):

    vowels = "aeiou"
    return letter in vowels
def stripFirst(word):

    first = word[0]
    rest = word[1:]

    return (first, rest)

def pigLatin(word):
    first, rest = stripFirst(word.lower())

    if isVowel(first):
    return rest + "way"
    else:
    return rest + first + "ay"


string = '{} is {} in piglatin'.format(word, pigLatin(word).title())

return string
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I added in a bit for the post processing to make things a bit prettier. &lt;br&gt;
In the future, I may extend this article a bit. Who knows?&lt;br&gt;
I hope you enjoyed reading my ramblings a bit though.&lt;/p&gt;


</description>
      <category>python</category>
      <category>orgmode</category>
      <category>programmingpractice</category>
    </item>
    <item>
      <title>Silly Name Generator</title>
      <dc:creator>D Smith</dc:creator>
      <pubDate>Fri, 07 Dec 2018 15:46:59 +0000</pubDate>
      <link>https://dev.to/zeeter/silly-name-generator-2f8k</link>
      <guid>https://dev.to/zeeter/silly-name-generator-2f8k</guid>
      <description>

&lt;h1&gt;
  
  
  Table of Contents
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt; Introduction
&lt;/li&gt;
&lt;li&gt; Name Lists

&lt;ol&gt;
&lt;li&gt; First Names
&lt;/li&gt;
&lt;li&gt; Last Names
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt; Choosing a Name
&lt;/li&gt;
&lt;li&gt; Main
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a id="org8fe4880"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;This is the first of the &lt;a href="https://nostarch.com/impracticalpythonprojects"&gt;Impractical Python&lt;/a&gt; book by Lee Vaughan.&lt;br&gt;
I aim to do every project in this book, as a literate program in my own style.&lt;br&gt;
As such please be kind, I am only a hobbyist that is aiming to learn.&lt;/p&gt;

&lt;p&gt;&lt;a id="org23be92e"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Name Lists
&lt;/h1&gt;

&lt;p&gt;&lt;a id="org1cf212e"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  First Names
&lt;/h2&gt;

&lt;p&gt;First things first, pun intended.&lt;br&gt;
We need to have a list for the python program to choose from.&lt;br&gt;
In python its easiest to do that with a list or tuple. The book used a tuple as it never&lt;br&gt;
changes durring execution so there is no need for a list.&lt;br&gt;
Admittedly I copy-pasted this section and the last names because I did not want to type them all.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;firstnames = ('Baby Oil', 'Bad News', 'Big Burps', "Bill 'Beenie-Weenie'",
     "Bob 'Stinkbug'", 'Bowel Noises', 'Boxelder', "Bud 'Lite' ",
     'Butterbean', 'Buttermilk', 'Buttocks', 'Chad', 'Chesterfield',
     'Chewy', 'Chigger', 'Cinnabuns', 'Cleet', 'Cornbread', 'Crab Meat',
     'Crapps', 'Dark Skies', 'Dennis Clawhammer', 'Dicman', 'Elphonso',
     'Fancypants', 'Figgs', 'Foncy', 'Gootsy', 'Greasy Jim', 'Huckleberry',
     'Huggy', 'Ignatious', 'Jimbo', "Joe 'Pottin Soil'", 'Johnny',
     'Lemongrass', 'Lil Debil', 'Longbranch', '"Lunch Money"', 'Mergatroid',
     '"Mr Peabody"', 'Oil-Can', 'Oinks', 'Old Scratch', 'Ovaltine',
     'Pennywhistle', 'Pitchfork Ben', 'Potato Bug', 'Pushmeet',
     'Rock Candy', 'Schlomo', 'Scratchensniff', 'Scut',
     "Sid 'The Squirts'", 'Skidmark', 'Slaps', 'Snakes', 'Snoobs',
     'Snorki', 'Soupcan Sam', 'Spitzitout', 'Squids', 'Stinky',
     'Storyboard', 'Sweet Tea', 'TeeTee', 'Wheezy Joe',
     "Winston 'Jazz Hands'", 'Worms')
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a id="orgdcd08b3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Last Names
&lt;/h2&gt;

&lt;p&gt;Same idea as firstnames. But for last names!&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lastnames = ('Appleyard', 'Bigmeat', 'Bloominshine', 'Boogerbottom',
    'Breedslovetrout', 'Butterbaugh', 'Clovenhoof', 'Clutterbuck',
    'Cocktoasten', 'Endicott', 'Fewhairs', 'Gooberdapple', 'Goodensmith',
    'Goodpasture', 'Guster', 'Henderson', 'Hooperbag', 'Hoosenater',
    'Hootkins', 'Jefferson', 'Jenkins', 'Jingley-Schmidt', 'Johnson',
    'Kingfish', 'Listenbee', "M'Bembo", 'McFadden', 'Moonshine', 'Nettles',
    'Noseworthy', 'Olivetti', 'Outerbridge', 'Overpeck', 'Overturf',
    'Oxhandler', 'Pealike', 'Pennywhistle', 'Peterson', 'Pieplow',
    'Pinkerton', 'Porkins', 'Putney', 'Quakenbush', 'Rainwater',
    'Rosenthal', 'Rubbins', 'Sackrider', 'Snuggleshine', 'Splern',
    'Stevens', 'Stroganoff', 'Sugar-Gold', 'Swackhamer', 'Tippins',
    'Turnipseed', 'Vinaigrette', 'Walkingstick', 'Wallbanger', 'Weewax',
    'Weiners', 'Whipkey', 'Wigglesworth', 'Wimplesnatch', 'Winterkorn',
    'Woolysocks')
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a id="orgfbbe1ca"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Choosing a Name
&lt;/h1&gt;

&lt;p&gt;To choose things, we need to use python's random module.&lt;br&gt;
Random does lots of neat things in generating sudo random numbers.&lt;br&gt;
Random.choice is what were gonna use for this one.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import random
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After the names are choosen, they are returned so that they can be displayed.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def chooser(firstnames,lastnames):
    firstname = random.choice(firstnames)
    lastname = random.choice(lastnames)
    return (firstname, lastname)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a id="org3d8d59a"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Main
&lt;/h1&gt;

&lt;p&gt;Finally, we put it all together.&lt;br&gt;
Technically, I should hafve written a "main" block, but this will work instead.&lt;br&gt;
Chooser is outside incase you need it for something.&lt;/p&gt;

&lt;p&gt;In essence, this program picks two names from a random list, returns them to the variables&lt;br&gt;
firstname and lastname, then prints them.&lt;/p&gt;

&lt;p&gt;Personally I think the original author used to many newlines, but whatever.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Check sillyname.org for details
 # Imports
import sys
import random

# Internal Functions
def chooser(firstnames,lastnames):
    firstname = random.choice(firstnames)
    lastname = random.choice(lastnames)
    return (firstname, lastname)




# Main script




def main():
    print("Welcome to the Pysch 'side kick name picker'!\n")
    print("A name just like Sean would pick for Gus:\n\n")
    firstnames = ('Baby Oil', 'Bad News', 'Big Burps', "Bill 'Beenie-Weenie'",
     "Bob 'Stinkbug'", 'Bowel Noises', 'Boxelder', "Bud 'Lite' ",
     'Butterbean', 'Buttermilk', 'Buttocks', 'Chad', 'Chesterfield',
     'Chewy', 'Chigger', 'Cinnabuns', 'Cleet', 'Cornbread', 'Crab Meat',
     'Crapps', 'Dark Skies', 'Dennis Clawhammer', 'Dicman', 'Elphonso',
     'Fancypants', 'Figgs', 'Foncy', 'Gootsy', 'Greasy Jim', 'Huckleberry',
     'Huggy', 'Ignatious', 'Jimbo', "Joe 'Pottin Soil'", 'Johnny',
     'Lemongrass', 'Lil Debil', 'Longbranch', '"Lunch Money"', 'Mergatroid',
     '"Mr Peabody"', 'Oil-Can', 'Oinks', 'Old Scratch', 'Ovaltine',
     'Pennywhistle', 'Pitchfork Ben', 'Potato Bug', 'Pushmeet',
     'Rock Candy', 'Schlomo', 'Scratchensniff', 'Scut',
     "Sid 'The Squirts'", 'Skidmark', 'Slaps', 'Snakes', 'Snoobs',
     'Snorki', 'Soupcan Sam', 'Spitzitout', 'Squids', 'Stinky',
     'Storyboard', 'Sweet Tea', 'TeeTee', 'Wheezy Joe',
     "Winston 'Jazz Hands'", 'Worms')

    lastnames = ('Appleyard', 'Bigmeat', 'Bloominshine', 'Boogerbottom',
    'Breedslovetrout', 'Butterbaugh', 'Clovenhoof', 'Clutterbuck',
    'Cocktoasten', 'Endicott', 'Fewhairs', 'Gooberdapple', 'Goodensmith',
    'Goodpasture', 'Guster', 'Henderson', 'Hooperbag', 'Hoosenater',
    'Hootkins', 'Jefferson', 'Jenkins', 'Jingley-Schmidt', 'Johnson',
    'Kingfish', 'Listenbee', "M'Bembo", 'McFadden', 'Moonshine', 'Nettles',
    'Noseworthy', 'Olivetti', 'Outerbridge', 'Overpeck', 'Overturf',
    'Oxhandler', 'Pealike', 'Pennywhistle', 'Peterson', 'Pieplow',
    'Pinkerton', 'Porkins', 'Putney', 'Quakenbush', 'Rainwater',
    'Rosenthal', 'Rubbins', 'Sackrider', 'Snuggleshine', 'Splern',
    'Stevens', 'Stroganoff', 'Sugar-Gold', 'Swackhamer', 'Tippins',
    'Turnipseed', 'Vinaigrette', 'Walkingstick', 'Wallbanger', 'Weewax',
    'Weiners', 'Whipkey', 'Wigglesworth', 'Wimplesnatch', 'Winterkorn',
    'Woolysocks')
    while True:
    firstname, lastname = chooser(firstnames, lastnames)
    print("{} {}".format(firstname, lastname, file=sys.stderr))
    print("\n\n")

    try_again=input("\n\nTry again? (press n to quit)\n")
    if try_again.lower() == 'n':
        break

    input("press Enter to exit")



if __name__ == '__main__':
    main()
    sys.exit()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to use it, justt run sillyname.py from the commandline.&lt;br&gt;
like so:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./sillyname.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;ant it will output something like this:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./sillyname.py
Welcome to the Pysch 'side kick name picker'!

A name just like Sean would pick for Gus:


Chesterfield Sugar-Gold





Try again? (press n to quit)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Overall, I hope you enjoyed this little read.&lt;/p&gt;


</description>
      <category>literateprogramming</category>
      <category>python</category>
      <category>programmingpractice</category>
    </item>
    <item>
      <title>Talking Clock Challenge</title>
      <dc:creator>D Smith</dc:creator>
      <pubDate>Sat, 30 Dec 2017 03:30:40 +0000</pubDate>
      <link>https://dev.to/zeeter/talking-clock-challenge-17p9</link>
      <guid>https://dev.to/zeeter/talking-clock-challenge-17p9</guid>
      <description>

&lt;h1&gt;
  
  
  Table of Contents
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt; Introduction
&lt;/li&gt;
&lt;li&gt; Description

&lt;ol&gt;
&lt;li&gt; Input Description
&lt;/li&gt;
&lt;li&gt; Output Description
&lt;/li&gt;
&lt;li&gt; Optional Challenge
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt; My Solution

&lt;ol&gt;
&lt;li&gt; Functional Test
&lt;/li&gt;
&lt;li&gt; Parsing the input
&lt;/li&gt;
&lt;li&gt; Converting intigers to words

&lt;ol&gt;
&lt;li&gt; Getting Hour String
&lt;/li&gt;
&lt;li&gt; Getting Minute String
&lt;/li&gt;
&lt;li&gt; Finding the period
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt; Putting it all together
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a id="orgd636e2d"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Challenge can be found &lt;a href="https://www.reddit.com/r/dailyprogrammer/comments/6jr76h/20170627_challenge_321_easy_talking_clock/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a id="org82c9658"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Description
&lt;/h1&gt;

&lt;p&gt;Create a program that can convert time strings into text.&lt;/p&gt;

&lt;p&gt;&lt;a id="org185d42f"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Input Description
&lt;/h2&gt;

&lt;p&gt;Input is an hour (0-23) followed by a colon followed by a minute (0-59)&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;00:00
01:30
12:05
14:01
20:29
21:00
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a id="orgcc22dc4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Output Description
&lt;/h2&gt;

&lt;p&gt;Program should output time in words, using the 12 hour format. (12:00 am)&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;It's twelve am
It's one thirty am
It's twelve oh five pm
It's two oh one pm
It's eight twenty nine pm
It's nine pm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a id="orgf0dd946"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional Challenge
&lt;/h2&gt;

&lt;p&gt;Make the program actually talk using sound clips, like the ones found &lt;a href="http://steve-audio.net/voices/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a id="org004c7f3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  My Solution
&lt;/h1&gt;

&lt;p&gt;So I have a solution for this that doesn't involve testing. However I have been trying to get into the habit of&lt;br&gt;
following Test Driven Development. Also I will be using a literate programming technique to write the program&lt;br&gt;
inside this article. The other thing I want to address is that I almost definately overengineered this too, &lt;br&gt;
I get a little zealous when I'm writting.&lt;/p&gt;

&lt;p&gt;&lt;a id="orgf30d35c"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Functional Test
&lt;/h2&gt;

&lt;p&gt;First things first, the following code block is the functional test for this challenge.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def talkingclock(time):
    hour,minute = map(int, time.split(":"))
    if hour &amp;gt;= 12:
        period = "pm"
    else:
        period = "am"
    numnames = (
        'one','two','three',
        'four','five','six',
        'seven','eight','nine',
        'ten','eleven','twelve')

    if hour &amp;gt; 12:
        hour -= 12
    else:
        pass

    hour_string = numnames[hour-1]
    minute_string = ""



    onetable = ("one","two","three",
                "four", "five", "six",
                "seven","eight","nine")


    teentable = ("ten","eleven","tweleve","thirteen",
                 "fourteen", "fifteen","sixteen",
                 "seventeen","eighteen","nineteen")

    tentable = ("","ten","twenty","thirty","forty","fifty",)

    if minute in range(1,10):
        minute_string = "oh " + onetable[minute-1]
    elif minute in range(10,20):
        minute_string = teentable[minute-10]

    elif minute in range(20,60):
        ones = minute % 10
        tens = minute - ones
        if ones &amp;gt; 0:
            minute_string = tentable[tens//10] + " " + onetable[ones-1]
        else:
            minute_string = tentable[tens//10]


    output = "It's " + hour_string + ' '
    if minute_string == '':
        output += period
    else:
        output += minute_string + ' ' + period

    return output

testtable = [i for i in zip(si.split(),so.split('\n\t'))]

results = [["Input","Expected Output","Actual Output", "Passed"]]

for test in testtable:

    si,so = test
    to = talkingclock(si)
    results.append([si,so,to,so==to])

return results
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This test works by gathering the sample input and sample output as described in the challenge section, it splits them into the proper lines&lt;br&gt;
and stores them as a list comprehension. I would have used tuples here, as the data never changes. However python creates generator objects&lt;br&gt;
if you replace square brackets with parenthesis when defining a listcomp. At that point I would be just as well using the stand alone zip fuction.&lt;br&gt;
Anyway the input string is fed into the talkingclock function and the output is compaired against the test output.&lt;br&gt;
This creates the above results, and if any of them are false, we can look at which line it occures on and test that input separately.&lt;br&gt;
While this is not the most elegant solution for testing, it is a rather practical test as we get a nice table out of it.&lt;/p&gt;

&lt;p&gt;&lt;a id="org8b561fc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Parsing the input
&lt;/h2&gt;

&lt;p&gt;The input that the talking clock is given is in the format of (HH:MM) in 24 hour time.&lt;br&gt;
To do this, we take the string and split it at the colon using the string's split method.&lt;br&gt;
This produces a of the strings for hour and minute. These are then turned into ints and assigned to&lt;br&gt;
the variables hour and minute respectively.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hour,minute = map(int, time.split(":"))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To test our parser works, we need to look for three things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; It returns an hour value&lt;/li&gt;
&lt;li&gt; It returns a minute value&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Both hour and minute are ints&lt;/p&gt;

&lt;p&gt;def testparser(time):&lt;br&gt;
    hour,minute = map(int, time.split(":"))&lt;br&gt;
    return hour,minute&lt;/p&gt;

&lt;p&gt;th,tm = testparser(test)&lt;/p&gt;

&lt;p&gt;isint = all(map(lambda x: type(x) == int, (th,tm)))&lt;br&gt;
hashour = th != None&lt;br&gt;
hasmin = tm != None&lt;/p&gt;

&lt;p&gt;results=(&lt;br&gt;
    ("Returns hour: ", hashour),&lt;br&gt;
    ("Returns minutes: ", hasmin),&lt;br&gt;
    ("All are ints: ", isint))&lt;/p&gt;

&lt;p&gt;return results&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Assuming when you run this test they all passed, we know that the parser is good to go.&lt;/p&gt;

&lt;p&gt;&lt;a id="org455ad6b"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Converting intigers to words
&lt;/h2&gt;

&lt;p&gt;Now that we have the input parsed into the correct form, we need to process it to get out the correct strings.&lt;/p&gt;

&lt;p&gt;&lt;a id="orge9533a1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Hour String
&lt;/h3&gt;

&lt;p&gt;Getting the hour string has a few requirements.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; The hour string  will always be between 1 and 12.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The hour string will be the english name for numbers (e.g) one&lt;/p&gt;

&lt;p&gt;numnames = (&lt;br&gt;
    'one','two','three',&lt;br&gt;
    'four','five','six',&lt;br&gt;
    'seven','eight','nine',&lt;br&gt;
    'ten','eleven','twelve')&lt;/p&gt;

&lt;p&gt;if hour &amp;gt; 12:&lt;br&gt;
    hour -= 12&lt;br&gt;
else:&lt;br&gt;
    pass&lt;/p&gt;

&lt;p&gt;hour_string = numnames[hour-1]&lt;/p&gt;

&lt;p&gt;def testhourstring(hour):&lt;br&gt;
    numnames = (&lt;br&gt;
        'one','two','three',&lt;br&gt;
        'four','five','six',&lt;br&gt;
        'seven','eight','nine',&lt;br&gt;
        'ten','eleven','twelve')&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if hour &amp;gt; 12:
    hour -= 12
else:
    pass

hour_string = numnames[hour-1]
return hour_string
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;nname = (&lt;br&gt;
    'one','two','three',&lt;br&gt;
    'four','five','six',&lt;br&gt;
    'seven','eight','nine',&lt;br&gt;
    'ten','eleven','twelve')&lt;/p&gt;

&lt;p&gt;zeroistwelve = (testhourstring(0) == 'tweleve')&lt;br&gt;
oneisoneect = all([testhourstring(i) ==  nname[(i-1)] for i in range(1,13)])&lt;br&gt;
thirteenisoneect = all([testhourstring(i) ==  nname[(i-1)] for i in range(1,13)])&lt;/p&gt;

&lt;p&gt;result = (&lt;br&gt;
    ("Test", "Passed"),&lt;br&gt;
    ("0 yields Tweleve: ", zeroistwelve),&lt;br&gt;
    ("1-13 yield correct name: ", oneisoneect),&lt;br&gt;
    ("13-23 yield correct name: ", thirteenisoneect)&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;return result&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a id="org083d48c"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Minute String
&lt;/h3&gt;

&lt;p&gt;The minute string is a bit more complex than the hour string.&lt;br&gt;
Effectively I have broken it up into a few parts&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; a ones table which runs from 1 to 9.&lt;/li&gt;
&lt;li&gt; a teens table which runs from 10 to 19&lt;/li&gt;
&lt;li&gt; a tens table which is 10 to 50&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For numbers that are 1-9 the string is made by fetching the number of off the ones table and appending it to the "oh" phrase.&lt;br&gt;
Because english is awful, I had to make the teen table, because the numbers that are 11-19 all have to be special and not conform to other numeric standards.&lt;br&gt;
Finally for numbers that are between 20-59 the number is made by fetching the tens space, and if it has a number in the ones space, apending that to it.&lt;br&gt;
The tens table also includes 10 to make some of my math easier, at the cost of making the tuple an element longer, which I think is a valid&lt;br&gt;
trade off.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;minute_string = ""



onetable = ("one","two","three",
            "four", "five", "six",
            "seven","eight","nine")


teentable = ("ten","eleven","tweleve","thirteen",
             "fourteen", "fifteen","sixteen",
             "seventeen","eighteen","nineteen")

tentable = ("","ten","twenty","thirty","forty","fifty",)

if minute in range(1,10):
    minute_string = "oh " + onetable[minute-1]
elif minute in range(10,20):
    minute_string = teentable[minute-10]

elif minute in range(20,60):
    ones = minute % 10
    tens = minute - ones
    if ones &amp;gt; 0:
        minute_string = tentable[tens//10] + " " + onetable[ones-1]
    else:
        minute_string = tentable[tens//10]






def testminstring(minute):
    minute_string = ""


    onetable = ("one","two","three",
                "four", "five", "six",
                "seven","eight","nine")


    teentable = ("ten","eleven","tweleve","thirteen",
                 "fourteen", "fifteen","sixteen",
                 "seventeen","eighteen","nineteen")

    tentable = ("","ten","twenty","thirty","forty","fifty",)

    if minute in range(1,10):
        minute_string = "oh " + onetable[minute-1]
    elif minute in range(10,20):
        minute_string = teentable[minute-10]

    elif minute in range(20,60):
        ones = minute % 10
        tens = minute - ones
        if ones &amp;gt; 0:
            minute_string = tentable[tens//10] + " " + onetable[ones-1]
        else:
            minute_string = tentable[tens//10]

    return minute_string



singledigit = testminstring(5) == "oh five"


teens = testminstring(15) == "fifteen"

justtens = testminstring(20) == "twenty"

tensandones = testminstring(35) == "thirty five"

doesnone = testminstring(0) == ""

results = (("test","passed"),
           ("Does single digits: ", singledigit),
           ("Does teens: ", teens),
           ("Does just tens: ", justtens),
           ("Does tens: ", tensandones),
           ("Does zero: ", doesnone)
)

return results
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This test used some hard coded values in it, unlike the hours test. However I needed to test for some specific conditions, and I figured&lt;br&gt;
a less robust test would work here better. Like with my hour tests, you could likely have it test all possible valid inputs with a list comp.&lt;br&gt;
But in this case, I'm not sure that it would be worth the effort.&lt;/p&gt;

&lt;p&gt;&lt;a id="org164c237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding the period
&lt;/h3&gt;

&lt;p&gt;To find the period, (am or pm) is a pretty simple task.&lt;br&gt;
This is done by taking the hour variable, and checking if it is greater than or equal to 12.&lt;br&gt;
If so the period is pm, otherwise it is am.&lt;br&gt;
What is important is that this piece must be run before getting the hour string, because the hour variable is change from that operation.&lt;br&gt;
This could be mitgated by storing the original value, however I think that would just be overcomplicating the issue.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if hour &amp;gt;= 12:
    period = "pm"
else:
    period = "am"

def testgetperiod(hour):
    if hour &amp;gt;= 12:
        period = "pm"
    else:
        period = "am"
    return period


amworks = all([testgetperiod(t) == 'am' for t in range(0,12)])
pmworks = all([testgetperiod(t) == 'pm' for t in range(12,23)])

results = (("test","passed"),
           ("Am works: ",amworks),
           ("Pm works: ",pmworks),
)

return results
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With a part this simple, tests really aren't needed. But I want to stay true to the bleepings of the testing goat. &lt;/p&gt;

&lt;p&gt;&lt;a id="org2109678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it all together
&lt;/h2&gt;

&lt;p&gt;Now that we have all the dependant parts, we just need to string them together in the right order.&lt;br&gt;
The main thing I look for here is if the minute string is empty or not.&lt;br&gt;
If it is, there should only be one space between the hour and the period.&lt;br&gt;
In one of my last attempts at this problem, I got tripped up at this stage, hense my caution.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def talkingclock(time):
    hour,minute = map(int, time.split(":"))
    if hour &amp;gt;= 12:
        period = "pm"
    else:
        period = "am"
    numnames = (
        'one','two','three',
        'four','five','six',
        'seven','eight','nine',
        'ten','eleven','twelve')

    if hour &amp;gt; 12:
        hour -= 12
    else:
        pass

    hour_string = numnames[hour-1]
    minute_string = ""



    onetable = ("one","two","three",
                "four", "five", "six",
                "seven","eight","nine")


    teentable = ("ten","eleven","tweleve","thirteen",
                 "fourteen", "fifteen","sixteen",
                 "seventeen","eighteen","nineteen")

    tentable = ("","ten","twenty","thirty","forty","fifty",)

    if minute in range(1,10):
        minute_string = "oh " + onetable[minute-1]
    elif minute in range(10,20):
        minute_string = teentable[minute-10]

    elif minute in range(20,60):
        ones = minute % 10
        tens = minute - ones
        if ones &amp;gt; 0:
            minute_string = tentable[tens//10] + " " + onetable[ones-1]
        else:
            minute_string = tentable[tens//10]


    output = "It's " + hour_string + ' '
    if minute_string == '':
        output += period
    else:
        output += minute_string + ' ' + period

    return output
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now with this version of the program, the output string is not printed to the&lt;br&gt;
stdout. I left that out for a few reasons. If I decide to do the optional challenge&lt;br&gt;
in the future, printing directly to the stdout won't be super helpful.&lt;br&gt;
Second, I wanted to keep the tests as simple as possible. If you notice, &lt;br&gt;
the above section never import code, this includes unittest. &lt;br&gt;
Unittest is a super helpful framework for more complicated tests, but I haven't&lt;br&gt;
figured out how to use it to make pretty tables. I may look into using nose in the future, but I haven't quite got there yet.&lt;/p&gt;


</description>
      <category>python</category>
      <category>orgmode</category>
      <category>programmingpractice</category>
    </item>
    <item>
      <title>An Examination of Fizzbuzz</title>
      <dc:creator>D Smith</dc:creator>
      <pubDate>Tue, 01 Aug 2017 06:59:34 +0000</pubDate>
      <link>https://dev.to/zeeter/an-examination-of-fizzbuzz</link>
      <guid>https://dev.to/zeeter/an-examination-of-fizzbuzz</guid>
      <description>&lt;h2&gt;Table of Contents&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;1. Introduction&lt;/li&gt;
&lt;li&gt;2. First Attempt&lt;/li&gt;
&lt;li&gt;3. Second Attempt&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;a id="orgad2678a"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;The fizz buzz problem is a type of programming challenge to show if a person knows how to program.&lt;br&gt;
Essentially the challenge goes like this, you must create a program that will print fizz every multiple of 3, buzz every multiple of 5,&lt;br&gt;
and fizz buzz on multiples of both fizz and buzz.&lt;br&gt;
&lt;em&gt;EDIT&lt;/em&gt; I forgot to mention that if n is neither a multiple of 3 or 5 it just prints the number.&lt;/p&gt;

&lt;p&gt;These are my attempts on this challenge.&lt;br&gt;
This article is ongoing as I am given new things to try.&lt;/p&gt;

&lt;p&gt;&lt;a id="org409ad2f"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  First Attempt
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;cond1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;cond2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;cond1&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;cond2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"fizz"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;cond2&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;cond1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"buzz"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;cond1&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;cond2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"fizz buzz"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the first try works as needed. However this method does not readly support changes.&lt;br&gt;
I did however make the choice based on conditions, however adding in additional conditions would be a pain.&lt;br&gt;
Also the code executes the moment that you run it, which is not a very good practice in the python land.&lt;/p&gt;

&lt;p&gt;&lt;a id="org248163d"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Second Attempt
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;argparse&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;if_multiple&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;multiple&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;multiple&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;''&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;n_if_empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;''&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;''&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fizzbuzz&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;stop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

        &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;''&lt;/span&gt;
        &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;if_multiple&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"fizz"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;if_multiple&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"buzz"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;n_if_empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;argparse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ArgumentParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"A program that plays fizzbuzz."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'start'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"The number to count from (Default 1)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'stop'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"The number to count to (Default: 100)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;fizzbuzz&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stop&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;




&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'__main__'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second version is better in my opinion. It no longer relies on messy else if logic, and is instead although I did not run this code through autopep8 so it is not necessarily pythonic. However this version is rather neat. You can import the fizzbuzz function if need be, and you can also import the other functions. Adding in a new bit of logic is as simple as adding in a new line. And changing the string to print is as simple as changing a variable.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt; I removed the bash calls from the code blocks, I still haven't quite figured out the org markdown export yet. This code should run without any syntax errors.&lt;/p&gt;

</description>
      <category>fizzbuzz</category>
      <category>python</category>
    </item>
    <item>
      <title>Hi, I'm Daniel Smith</title>
      <dc:creator>D Smith</dc:creator>
      <pubDate>Wed, 22 Feb 2017 20:45:22 +0000</pubDate>
      <link>https://dev.to/zeeter/hi-im-daniel-smith</link>
      <guid>https://dev.to/zeeter/hi-im-daniel-smith</guid>
      <description>&lt;p&gt;I have been coding for ~5 years.&lt;/p&gt;

&lt;p&gt;You can find me on Twitter as &lt;a href="https://twitter.com/nalisarc" rel="noopener noreferrer"&gt;@nalisarc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in Salt Lake City.&lt;/p&gt;

&lt;p&gt;I work for University of Utah.&lt;/p&gt;

&lt;p&gt;I mostly program in these languages: python, and lisp.&lt;/p&gt;

&lt;p&gt;I am currently learning more about python, data science.&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
