Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Jupyter notebook assignments/Week2/piglatin.ipynb

119 views
Kernel: Python 2 (SageMath)
# Compute a (simplified) Pig Latin version of a word. ################################################### # Pig Latin formula def pig_latin(word): """Returns the (simplified) Pig Latin version of the word.""" first_letter = word[0] rest_of_word = word[1 : ] # Student should complete function on the next lines. ################################################### # Tests # Student should not change this code. def test(word): """Tests the pig_latin function.""" print pig_latin(word) test("pig") test("owl") test("python") ################################################### # Expected output # Student should look at the following comments and compare to printed output. #igpay #owlway #ythonpay
def pig_latin(word): """Returns the (simplified) Pig Latin version of the word.""" first_letter =word[0] rest_of_word =word[1 : ] if first_letter in('a','e', 'i', 'o' ,'u'): print (first_letter + rest_of_word + "way") else: print (rest_of_word + first_letter+ "ay") def test(word): """Tests the pig_latin function.""" print pig_latin(word) test("pig") test("owl") test("python")
igpay None owlway None ythonpay None