3.7. Chapter 3 Exercises¶
There are 3 syntax errors in the following code. Fix it to print correctly without errors. It will print, “Your name is Carly and your favorite color is red.”.
You will get an error if you try to run the following code. Fix the code to print correctly without errors. It should print, “Your name is Carly and your age is 19.”
Note: Don’t forget that to turn an int into a string you do something like
x is the int you want to turn into a string.
Use string slicing to get “giant alligator” from
sentence and store it in
You should not be typing the string “giant alligator” yourself, you should be
getting the right part of what is stored in
The print will put |’s around your output to make it clear if you have a space at the start or end of s1.
Using the variables given, modify the print statement to print
"A car travelling at 70 mph takes 2.0 hours to go 140 miles."
Make sure to print the variables, not the values you know they contain.
If we were to change
distanceTravelled your program should still print a
mathematically correct message.
Write code below to get at least 3 values from the user using the
input function and output
a mad lib (which will use the input to tell a silly story).
This problem is not automatically checked. Make sure you are using variables to build your output and that the story uses the values you type in as input. Try giving different inputs and make sure that the story uses them.