My First Python program “Pyg Latin Translator”

Just finished creating my first program on Code Academy called “An English to Pyg Latin Translator” while learning Python programming language.

What it does?

From Codecademy: Pyg Latin is basically a language where we take the first letter of a word and put it on the end while also adding a vowel sound. So dog becomes “ogday”.

Here is the code I wrote in a step by step process:

pyg = 'ay'

original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
if (len(original) > 0 and original.isalpha()):
    if (first == 'a' or first == 'e' or first == 'i' or first == 'o' or first == 'u' or first == 'A' or first == 'E' or first == 'I' or first == 'O' or first == 'U'):  
        new_word = word + pyg
        print new_word
    else:
    	new_word = word[1:] + word[0] + pyg
        print new_word
else:
	print 'You have not entered a valid word. (Alphabetical Characters only!).'

This program lacks commenting as of now, however, considering the simplicity of the program, commenting might not be even required as of now.

Its definitely fun, working out a logical structure (an algorithm / a flow) for a particular program and then starting to code small parts of a program, that ultimately when combined result into a fully functional program.

Advertisements
This entry was posted in Code Academy, Fun with Python and tagged , , , , , , , , , , , , , , , , , . Bookmark the permalink.

4 Responses to My First Python program “Pyg Latin Translator”

  1. hey there and thank you on your info ? I’ve certainly picked up something new from proper here. I did however expertise several technical points using this website, as I skilled to reload the site a lot of times previous to I may just get it to load correctly. I were brooding about if your hosting is OK? Not that I am complaining, but sluggish loading circumstances occasions will sometimes impact your placement in google and could injury your high-quality score if ads and marketing with Adwords. Anyway I am including this RSS to my e-mail and can look out for a lot extra of your respective exciting content. Make sure you replace this once more very soon..

  2. Pingback: My Second Python Program – BattleShip Game | Learner's Learning experiences...

  3. Bavarian says:

    Good job dude.Keep up learning.I’m new at codeacademy and i’m at this lesson.Python is very nice to language for learning.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s