9.6. Chapter 9 Exercises¶
Fix 5 errors in code below to correctly print: “Rubber baby buggy bumpers.”
The code currently prints the reverse of a string. Change it so that it prints the string in the correct order, but every character is separated by a space (there should even be a space between a space and the next character).
Fix the indention on 4 lines below to correctly print the reverse of the string. It should print: “!yadhtriB yppaH.”
Fix the errors in the code to correctly print the reverse of the string. It should print: “!gnirts a m’I ,kool yeH”
Fix 4 errors in the code below to correctly print the mirror of the text in phrase. It should print: “tset a si sihTThis is a test.”
The code currently prints each letter of the string twice in a row. Change it so that it prints the mirror of the string. It should print: “!rorrim a ni gnikool ekil s’tIIt’s like looking in a mirror!”
The code below is supposed to replace all 1’s with i’s, but it is in an infinite loop. You can reload the page to stop the infinite loop. Add a line to make the code work. It should print: “This is a string.”
Fix the errors so that the code prints “I’m just a string.”
The program below is supposed to encode the text in message, but it has 5 errors. Fix the errors so that it prints: “nvvg.nv.zg.nrwmrtsg.”
The code currently prints “This is a striniThis is a string”. Fix the error so that it replaces every “1” with “i” and prints “This is a string”.
Rewrite the following code to create a function that takes a string and returns the reverse of the string. It should print: “!yadhtriB yppaH.”
Fix the errors in the code so that it replaces the misspelled word “recieved” with the correct spelling “received”
Rewrite the following code to create a function that takes a string and returns the mirror of the string. It should print: “!ssalC iHHi Class!”.
Complete the code to change all the periods to commas.
Modify the code below to create a function that will that will take a message and return an encoded message. It should print: “nvvg.nv.zg.nrwmrtsg.”
Rewrite and fix the errors in the code to be a procedure that takes in a string and prints the reverse of the string and the mirror of the string. Make sure to call the procedure.
Modify the code below to create a function that returns the decoded input string. It should print: “meet me at midnight.”
Finish the code so that it prints the mirror of the string with the correct way then the reverse. It should print: “This is a mirror!!rorrim a si sihT”
Create another function that encodes a string. Pass in both the string to be encoded and the string to use to encode the string as well.
Here’s the code to encode a message. Write code underneath it to decode the encoded message and print it.