17.8. Chapter 17 Exercises

  1. Fix 6 syntax errors in the code below so that the code runs correctly. It will print a story.

    Show Comments
  2. Fix the errors so that it prints the first and last name only.

    Show Comments
  3. Fix the 6 syntax errors in the code below so that it runs. It will print a story.

    Show Comments
  4. Complete the code on lines 8 - 12 to initialize the variables correctly according to the order of the input.

    Show Comments
  5. Indent 6 lines and fix the call to the procedure so that it works correctly. It will print a story.

    Show Comments
  6. The input is a list of strings, add code below it (and fix indentation and variable names if needed) so that the code will print a story for each string in the list.

    Show Comments
  7. Change 4 lines in the code below so that runs correctly without any errors. It will print a poem.

    Show Comments
  8. Fix the 6 errors so that the code prints the story properly.

    Show Comments
  9. Turn the following code into a function. It finds the name in a string and prints it. Pass in the string and return the name if it is found and “Unknown” if not. Be sure to call the function to test it. Test it both when the name is there and when it isn’t.

    Show Comments
  10. The procedure below takes a string and splits it to create a story. Change it so that it takes multiple strings, so it creates the story without having to use split.

    Show Comments
  11. Change the following code into a function that prints a crazy headline. It should take the values as parameters. Be sure to call the function to test it.

    Show Comments
  12. Fix the 3 errors to make the code print out the age.

    Show Comments
  13. Change the following into a procedure that prints the following story. Pass in the values that can change.

    Show Comments
  14. Change the following into a procedure that takes one string in the format “name: Bob, age: 10”. The procedure should print the name and age.

    Show Comments
  15. Write a personalized story. It should start with a string of input and split that string to get the parts it needs for the story. For example, define a name, animal, animal name, and animal adjective and create a story from that.

    Show Comments
  16. Write a procedure that takes in a string with 2 adjectives, a noun, and a verb separated by a comma (ex: “crazy,blue,banana,runs”) in that order and prints a sentence using all 4 words.

    Show Comments
  17. Write a procedure that prints a personalized story. It should take as input the items that will allow you to personalize a story.

    Show Comments
  18. Write a procedure that takes in a name, age, and 2 verbs. If the age is less than 10, print a sentence using the name, age, and first verb. Otherwise print a sentence using the name, age, and second verb.

    Show Comments
  19. Write a procedure that prints a personalized story. It should take as input the items that will allow you to personalize a story. It should also take a gender and vary the story based on the gender.

    Show Comments
  20. Create a procedure that takes in a string like “name: Bob,age: 10,verb: dance” and prints out a sentence with just the name, age, and verb.

    Show Comments
You have attempted of activities on this page