Chapter 9 Exercises

  1. Fix 5 errors in code below to correctly print: “Rubber baby buggy bumpers.”

    Show Comments
  2. 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).

    Show Comments
  3. Fix the indention on 4 lines below to correctly print the reverse of the string. It should print: “!yadhtriB yppaH.”

    Show Comments
  4. Fix the errors in the code to correctly print the reverse of the string. It should print: “!gnirts a m’I ,kool yeH”

    Show Comments
  5. 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.”

    Show Comments
  6. 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!”

    Show Comments
  7. 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.”

    Show Comments
  8. Fix the errors so that the code prints “I’m just a string.”

    Show Comments
  9. 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.”

    Show Comments
  10. 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”.

    Show Comments
  11. Rewrite the following code to create a function that takes a string and returns the reverse of the string. It should print: “!yadhtriB yppaH.”

    Show Comments
  12. Fix the errors in the code so that it replaces the misspelled word “recieved” with the correct spelling “received”

    Show Comments
  13. 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!”.

    Show Comments
  14. Complete the code to change all the periods to commas.

    Show Comments
  15. 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.”

    Show Comments
  16. 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.

    Show Comments
  17. Modify the code below to create a function that returns the decoded input string. It should print: “meet me at midnight.”

    Show Comments
  18. 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”

    Show Comments
  19. 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.

    Show Comments
  20. Here’s the code to encode a message. Write code underneath it to decode the encoded message and print it.

    Show Comments
Next Section - Chapter 10 - Repeating Steps with Turtles