Python (Fall 2026) Module 2-11: A2 Explanation (Using online-python.com)
Overview
Bill Moseley explains Assignment A2, a Python Mad Libs program that collects roughly four or five user inputs, cleans them with methods such as strip(), and inserts them into a story using an f-string or str.format(). He demonstrates multiline strings in online-python.com, suggests using an AI-generated story as an optional template, and shows students how to download and submit the correctly named a2.py file.
Key takeaways
- Mad Libs provides a practical exercise for gathering four or five inputs and inserting them into a story with Python f-strings or str.format().
- Use .strip() on input() responses to remove unwanted surrounding whitespace before placing answers into a story.
- A multiline f-string requires a defined Python variable for every placeholder; descriptive names such as strAdj1 and strNoun1 help distinguish repeated word types.
- AI can generate an optional Mad Lib prompt, but the core assignment is practicing input collection, cleanup, string formatting, and output.
- Online-python.com submissions must be downloaded as the actual source file, named exactly a2.py for Assignment 2, rather than submitted as an image.
Chapters
- A2 uses the Mad Libs format to practice Python string formatting with four or five user-provided words or details.
- Bill Moseley demonstrates collecting values with input() and cleaning responses with .strip().
- An f-string and a multiline string combine values such as a name, age, and school into printable text.
- Python's paired delimiters must match, including triple quotes and braces used for f-string placeholders.
- The course's Module 2 starter files include an a2 template with a multiline Mad Lib and blanks to replace.
- Each placeholder needs a matching defined variable and an f-string prefix, or Python will flag undefined variables.
- Bill demonstrates descriptive names such as strNoun1, strVerb, and strAdj1, with separate variables when a word type appears more than once.
- Students may use the template, write their own story, or ask AI for a short Mad Lib, such as one about a day at the beach.
- The assignment is graded on collecting and cleaning input, inserting it into text with an f-string or str.format(), and printing the result, not on the story itself.
- In online-python.com, use Save and select Current file only to download the program.
- Name the Assignment 2 file exactly a2.py in lowercase, then save it somewhere easy to find, such as the desktop.
- Students who submitted a screenshot or phone photo for Assignment 1 should resubmit the actual program text, and Moseley encourages asking classmates or consulting course materials for help.
Transcript excerpt
0:00 So, A2. In A2 we are doing what are called Mad Libs. I don't know if you know what a Mad Libs is, but it's a tool for teaching kids the parts of speech. So it's typically a little story that has a bunch of underlines in it. Things like adjective, a noun, a food, part of your body. And little kids have a lot of fun filling in silly words. And about half of all Mad Libs are filled in with things like poop and fart and, like, you know, because kids, right? I see you have the same sense of humor I do. So the point is you're teaching kids the difference between like a noun and a verb and things like that. But this is a great opportunity for us to practice using
0:56 string format or f-strings. And I'm okay with you using either method. If you want to play around with string format, you can. If you want to use an f-string, you can use an f-string. But basically, what I want you to do is I want you to get four or five inputs from the user, put those into variables, and then insert those into text. Okay? So what that's going to look like, and I'll do it first in, now let's go straight to online Python. So I'm going to, in online Python here, I'm going to delete that program and I'm going to start by getting a few inputs. I'm going to say strName equals input.
1:52 What is your name? And of course I'm going to strip that. And then I'll say strAge, put what is your age, dot strip. And input. Where do you go to? Now, I'm not giving you an actual Mad Libs yet. I'm just showing you sort
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.