Question
First, building on what we learned about escape characters in strings (the and options), there are some other escape sequences in Python, all
First, building on what we learned about escape characters in strings (the \ and \ options), there are some other escape sequences in Python, all beginning with a \ character. Try experimenting by printing out strings containing the following escape characters, to see what they do:
, \t, \\, \b. If you cannot deduce what these do, feel free to look them up in an online Python guide.
Make sure that each member of your team understands how each of those characters work.
You are each going to write a short program to generate mad-libs. A mad-lib is a short story in which a person is asked for some general terms (e.g. Number from 10 to 18 and Name of a river), and then that term is inserted into some story. For instance, if the person entered 15 and Brazos, then the story might read: I was 15 years old when I decided to sail a raft down the Brazos River.
- As a team, decide on at least 5 and no more than 10 different inputs that you will ask a user for. Agree on these as a team (e.g. they can be things like A persons name, The name of a city, A color, A word ending in -ing.
- At least one of these inputs should be a numerical value.
- Then, each member should individually write a mad-lib program that forms a story using those inputs. The story should:
- Perform at least one computation on the numerical input. For example, you might ask for an age in years, and convert it to months.
- Generate several sentences in a story that incorporates all of the input the user typed in.
- Present the story in a nicely formatted manner. The lines of text should be of reasonable length and flow into each other, without having single words on a line (unless at the end of a paragraph), et
- Your text should make use of the escape characters: , \t, and either \ or \, somewhere within the text.
- Try out other teammates programs. As a team, decide which program performs best and submit it as a team assignment.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started