For Project 1, we're kicking things off with a fun and educational project: a Mad Libs game in Python. As we go along, you'll not only learn some Python basics but also get a practical introduction to some key software engineering concepts.
By the end of this project, you will have gained valuable experience and foundational skills that will be useful for future projects:
Creating step-by-step plans (algorithms) for solving problems
Working with Python, a popular programming language
Changing and formatting text (strings) in various ways
Asking users for information and showing messages on the screen
Combining text and variables using f-strings for easier formatting
Breaking up text into smaller parts using the split method
These skills are essential for anyone starting in programming and will help you tackle more complex projects in the future.
This is all about understanding what the client wants and what you're making before you start coding.
What are the main goals and key features of the program?
Listen to Jim below, he has a program he wants you to build. If you're still not sure afterwards, you can chat with him using the interface to the right.
📖 Afterwards, write down three requirements into your workbook, in plain-English, that you think Jim wants you to include in the program.
An example of this might be: "The program should greet the user and explain that it is a Mad Libs game".
Specifications are a "blueprint" that describes how the Requirements will actually be implemented. Here, we decide exactly what the program will do based on the requirements such as the specific inputs and outputs that will be used.
📖 In your workbook, complete the activity in which you list the inputs and outputs of this program.
For example, you might come up with the output first:
One day, a speeding hedgehog decided to run to Green Hills. Along the way, the hedgehog met a curious fox. The fox said, "I'm so lost! Can you help me find my Chaos Emerald?" The hedgehog agreed, and they zoomed together through the Labyrinth Zone. Finally, they found the Chaos Emerald, and the fox exclaimed, "Thank you, my speedy friend! You're the best hero a fox could ever have!"
From there, you can begin to identify the inputs:
One day, a [adjective1] [animal1] decided to [verb_base] to [place]. Along the way, the [animal1] met a [adjective2] [animal2]. The [animal2] said, "I'm so [adjective3]! Can you help me find my [object]?" The [animal1] agreed, and they [verb_past] together through the [place]. Finally, they found the [object], and the [animal2] exclaimed, "Thank you, my [adjective1] friend! You're the best [animal1] a [animal2] could ever have!"
In this example, the final story is the output, and I have planned for the following inputs:
adjective1
adjective2
adjective3
animal1
animal2
place
object
verb - base
verb - past tense
Design is your game plan. Before you start coding, you sketch out what steps your program needs to take and how it should flow.
📖 In your workbook, complete the screen design and flowchart activities.
Screen Design:
By completing this you can understand exactly how the program works from the user's perspective.
----------------------------
REVERSE A WORD
----------------------------
Welcome to the Word Reverser.
Please enter a word to reverse: sandwich
Here is your reversed word: hciwdnas
Press any key to exit...
Flowchart:
Flowcharts provide a visual representation of the logic flow of the program, breaking it down into manageable pieces.
Once you've laid it out visually, translating it into code becomes a much more straightforward task.
Now comes the fun part: actually making your program. This is where you write the code. Link to Project 1 - Mad Libs
There are four labs to complete in order to learn the concepts necessary to complete this project. Complete these first.
Lab 1 - Hello World
Learn the basics of Python programming by creating a simple "Hello, World!" program.
Get set up on GitHub so that your projects are safely versioned and backed up.
Learn to use the input function to get the user's name and display a personalized greeting.
Prompt the user for their first and last names separately, and display a personalized greeting using both names.
Learn to use f-strings and some basic string methods, such as capitalize, to format the output.
Learn to use the split method to separate a user's full name into first and last, and display a greeting using only their first name.
Yes, Jim is the client - but as your teacher I feel like I should impose some requirements and specifications of my own, so that you know what is expected of a good program.
I have broken these down into two categories: less comfortable - for those of you that may be new to coding or currently find it challenging, and more comfortable - for those of you after a bit more challenge.
Less Comfortable:
Use variables to store user input.
Use the 'print' function to display the final story.
Use the 'input' function to get user input.
Use string concatenation to create the final story containing at least four variables.
Make use of 'capitalize' on at least one variable.
Handle edge cases, such input with extra spaces with the 'strip' method.
More Comfortable
Use all requirements from above.
Use chaining to demonstrate multiple string methods applied to a single string.
Use 'f-strings' for creating the final story.
Ask for a full name and ensure that both parts are capitalised with 'title'.
Use the 'split' method to separate the full name into first and last names.
Use both the full and first name somewhere in the story
Use the 'upper' method to emphasize a certain part of the story
Implement a more complex story template with at least eight variables.
You may or may not have 'bugs' or problems during the development of this program. If you do, here are a few tips.
Understand the error message - Google might help you here.
Print statements - print out the values of variables to understand what is happening in your program.
Comment out code - This can help you isolate the issue
Rubber duck debugging - Explaining the code aloud as if it were to someone else can sometimes lead to a solution
Manual tracing - Go line by line through your program, the error might not be where you think it is
Change one thing at a time - otherwise you'll have even more headaches!
Get Help - Utilise the AI Tutor, a peer, your teacher or Google.
For your first project at least run the program a few times and test that it works. Perhaps get a peer to test it.
If you want to test it more thoroughly, think about ways you could 'break' it. E.g. Not entering a value, using numbers etc
Sometimes programs are updates with more features or as bugs are found. In order to come back to a program we have previously worked on, or even work on someone elses code, we should ensure that our code is easily maintainable. For this project we can do this in two ways:
Ensure you have used easy to read variable names that make sense.
E.g. Don't use 'n' when you could use 'name'.
Readability: Clear names make code easier to understand.
Debugging: Good names help quickly identify errors.
In addition to the above, it helps to explain what certain sections of code do and how they work. You don't need to comment every line either, be purposeful with your commenting.
Clarification: Comments explain the "why" behind code.
Ease of Updating: Comments make future changes easier.
Go back through your program and ensure it is maintainable!
Poor Maintainability:
Good Maintainability: