Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write the code in python please! i think i have the first figured out (code at bottom). i cant figure out the silly_strings, any help

write the code in python please! i think i have the first figured out (code at bottom). i cant figure out the silly_strings, any help is appreciated!!! i will upvote it works! image text in transcribed
image text in transcribed
image text in transcribed
Write a function called reverse_alternate_words(input_string) that takes in a string and returns a new string where every other word is reversed. For the purposes of this exercise, a word is defined as a sequence of non-space characters. Examples: reverse_alternate_words("This is a test string") returns "sihT is a test gnirts" reverse_alternate_words("I love programming in python") returns "I love gnimmargorp in nohtyp" reverse_alternate_words("I'm a master problem solver") returns "m'l a retsam problem revlos" 2. Ted the TA doesn't know what lists are. He thinks they were just strings with commas in them like "T,E,D,i,S,S,I,L,L,Y" instead of ["Ted",'Is,"'Silly"]. Each new word alternates between uppercase and lowercase letters. Now, this is just plain silly. Help Ted out and make a function called silly_strings(string) that takes in one of Ted's silly strings, finds all the words, capitalizes them, and adds them into a list. Examples: silly_strings("T,E,D,i,s,S,I,L,L,Y") returns ['Ted','Is','Silly'] silly_strings("M,Y,t,a,s, A, R, E, r,e, a, I,I,y,A,W,E,S, C returns ['My', 'Tas', 'Are', 'Really', 'Awesome'] silly_strings("I,I,i, k,e,F,O,U,N,T,A,I,N,d,i,n,i,n,g,H returns ['I', 'Like', 'Fountain', 'Dining', 'Hall'] 3. Test each function by creating a test function that uses if statements to compare expected and actual results. Each test function should have 2 test cases. Call the test functions in main() to receive full credit (this means you need to indent!)

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_2

Step: 3

blur-text-image_3

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

Explain why the lattice energy of KCl is greater than that of KI.

Answered: 1 week ago