Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write in python, thanks! Question 1: snake2pig (10.0 marks) For the first question of this assignment, you will design and write a program -

Please write in python, thanks!

image text in transcribedimage text in transcribedimage text in transcribed

Question 1: "snake2pig (10.0 marks) For the first question of this assignment, you will design and write a program - in either Python 3 or Java (your choice) - that uses several recursive algorithms to produce a sequence of words in "Pig Latin" from an initial string in "Snake Case". You must carefully read the instructions below before proceeding. A string that is written in "Snake Case" uses only lowercase letters and each word is separated by an underscore. Any word can be written in "Pig Latin" by removing all the characters in the word (starting from the left and moving to the right, up to but not including the leftmost vowel (specifically one of"A", "E", "I", "O", or "U") contained in the word. Without changing their order, these characters must be appended to the end of the word, and then the characters "AY" must be appended to the end of that. By way of clarification, the word "ROBERT" would be transformed to "Pig Latin" by moving the "R" (i.e, all consonants from the left up to but not including the leftmost vowel) to the end of the word (to create "OBERTR") and then appending "AY" to produce "OBERTRAY".A word like THIRTY, in which there is more than one non-vowel character at the beginning of the word, would have the substring TH moved to the end, followed by "AY" to produce "IRTYTHAY" as the result. A word like EIGHT, in which the leftmost vowel is at position 0 would have no characters that must be moved to the end and would thus simply be "EIGHTAY" The conversion of a string in "Snake Case" into "Pig Latin" requires transforming the initial Snake Case" string into a list of words, and then transforming each word into "Pig Latin". As a clarifying example, the "Snake Case" string: "robert_is_thirty_eight" would be parsed into a list of words (at the underscores) ["robert", "is", "thirty", "eight"] and then each word would be converted to "Pig Latin": "obertray", "isay", "irtythay", "eightay"] The objective of this question is to have you revisit the paradigm shift we discussed in the first lecture, where you as the designer focus your efforts, not upon describing "how" a result might be computed but instead upon "what" each of the components is. Since we will (very shortly) be using recursive design exclusively, each of these definitions - except (e) MUST be recursive in nature. You are not permitted to use looping control structures anywhere in this program. Your solution must meet the following requirements: you must write a recursive function that will validate (ie, return True or False) that the string passed as an argument does not use any uppercase letters, a) b) you must write a recursive function that will take a string as an argument and produce an integer return value for the index of the leftmost underscore in the string, c) you must write a recursive function that will take a string as an argument and produce a list of strings as a return value such that the argument string has been "split" at each instance of the underscore, using the function you wrote for (b) above, d) you must write a recursive function that will take a string as an argument and produce an integer return value for the index of the leftmost vowel in the string, e) you must write a function (which will NOT be recursive) that will take a string as an argument and produce a string return value by changing that "word" into "Pig Latin", using the function you wrote for (d) above, and you must write a recursive function that will take a list of strings as an argument and produce a list of strings as a return value such that every element of the argument list has been passed to the function you wrote for (e) above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

6. Have you used solid reasoning in your argument?

Answered: 1 week ago