LAB 4

PigLatin:

The piglatin lab was one of the hardest labs that I have come across so far. This lab me just about 2 weeks to complete. One of my main problems was understanding the code and process i was doing. Not only that but i was also rushing my self and ended up was skipping important steps to code I was working on. The code that I did involved if and else statement along with several other variables. The purpose of the final code was dependent on weather or not the word typed into the mainframe was a consent or a vowel. If the first letter was a vowel it would add on certain letters to the word. While if it was a constant it would add on a different set of letters. The code I used can be seen below along with a screen shot of the final outcome.

Code:

pyg = ‘ay’
original = raw_input(‘Enter a word:’)
if len(original) > 0 and original.isalpha():
print original
word = original.lower()
first = word[0]
if first == “a” or first == “e” or first == “i” or first == “o” or first == “u”:
#print “vowel”
new_word = word + pyg
print new_word
else:
word_length = len(word)
print “The length of the word is: ” + str(word_length)
word_latter = word[1:word_length]
print “The latter part of the word is: ” + word_latter
new_word = word_latter + word[0] + pyg
print new_word
else:
print ’empty’

 

 

Capture

Leave a Reply

Your email address will not be published. Required fields are marked *