Before you keep reading...
Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
17.8. Chapter 17 Exercises¶
Fix 6 syntax errors in the code below so that the code runs correctly. It will print a story.
Fix the errors so that it prints the first and last name only.
Fix the 6 syntax errors in the code below so that it runs. It will print a story.
Complete the code on lines 8 - 12 to initialize the variables correctly according to the order of the input.
Indent 6 lines and fix the call to the procedure so that it works correctly. It will print a story.
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.
Change 4 lines in the code below so that runs correctly without any errors. It will print a poem.
Fix the 6 errors so that the code prints the story properly.
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.
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.
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.
Fix the 3 errors to make the code print out the age.
Change the following into a procedure that prints the following story. Pass in the values that can change.
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.
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.
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.
Write a procedure that prints a personalized story. It should take as input the items that will allow you to personalize a story.
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.
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.
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.