Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could someone write both programs in python. Please DO NOT use print(). Please use return(). . def simple_pig latin(input, sep- , end.: Accept a string

Could someone write both programs in python. Please DO NOT use print(). Please use return(). image text in transcribed
. def simple_pig latin(input, sep-" ", end.": Accept a string input, which might include multiple words separated by a separator sep and perform the following steps: more characters Find the list of "words" (Note: "words" are just "zero or symbol". So, depending on the separator or 'a..b' could be a "word"). Inspect every "word" and apply the following conversions: o o if the word starts with a non-letter or contains no characters, do nothing to it if the word starts with a vowel, add 'way' to the end if the word starts with a consonant, place the first letter at the end and add 'ay - Reassemble the words back into one string and return it, making sure a single sep is padded between any two neighboring words and the final string ends with end. o o Assume: the input does not have any capital letters o Go ahead and use string methods like .join(), split) o simple_ pig latin("i like this") o simple_pig_latin("1 iike this", sepe',') . like thisway,' o simple pig latin("i-like-this, o simple_pig latin("i.like.this",sep. ,end')- iway.ikelay.histay! iway ikelay histay # default sep(space) and end(dot) # separator is dot, so 'hole thing is a single "word" # sep is '-' and default end(dot) #sep is and end is .!' iway-ikelay-histay. o simple pig latin(".") # only word is , so do nothing to it and add a to the end def replace(xs,old, new, limit-None): Given a list xs, replace occurrences of old value with new value. An optional fourth argument limit is an integer states the maximum number of replacements allowed. You should only replace up to the first limit occurrences of old and leave the rest unchanged. When limitNone, there's truly no limit (and we replace all occurrences ofold). Negative or zero limit: no replacement o o Examples: Assume: xs is a list; xs could be empty. Return None, because the replacement happened in-place. o >>> xs [1,2,1,3,1,4,1,5,1] >>> replace(xs,1,-1) >>> Xs #returns None t-1, 2, -1, 3, -1, 4, -1, 5, -1] #replace all o > xs [1,2,1,3,1,4,1,5,1] >> replace(xs,1,-1,2) >>> XS #replace only the first 2 occurrences >>> xs = [1,2,1,3,1,4,1,5,1] >>> replace(xs,1,-1,-100) >>> xs replace none

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

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

ISBN: 3030302776, 978-3030302771

Students also viewed these Databases questions