Lab 4

Lab description:

In this lab, I used pig Latin translator to test a word within my own specified parameters. The first step of this lab was to set the variable pyg = “ay”. This was to be used by the translator to put the word in the form it was suppose to be in if it wasn’t already in that form before the test. The next step was to check the first letter of the word to see if it was a vowel. If it was a vowel I had it set to return “vowel”. If it was not a vowel, I set it so it would take out the first letter of the word and add pyg to the end which added “ay”. By putting ay at the end of the word it fit the parameters in Codecademy and cleared the section. This can be seen in the script and screenshot down below.

Script :

  • pyg = ‘ay’
  • original = raw_input(‘Enter a word:’)
  • if len(original) > 0 and original.isalpha()
  • word = original[0]
  • if word is [‘a’,’e’,’i’,’o’,’u’]:
  • print “vowel”
  • else:
  • print new_word[1:2]  + pyg
  • else:
  • print “empty” new_word = “cay” print

Screenshot:

 

lab 4 screenshot

Leave a Reply

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