- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Core Tech
Potion Pairing in Python
Build a beginner-friendly Python command-line app that evaluates potion ingredient pairings. You will implement input normalization, condition-based outcome rules, validation, and a small import-driven random selection flow while keeping the game logic separated from the CLI entry point.
Lab Info
Table of Contents
-
Challenge
Introduction
In this lab, you will build a small Python command-line application that evaluates ingredient pairings for a potion workshop. The project is intentionally compact so you can focus on core language skills: comparing strings, writing
ifandelifbranches, validating input, and importing a standard-library module to add dynamic behavior. info> This lab experience was developed by the Pluralsight team using an internally developed AI tool. All sections were verified by human experts for accuracy prior to publications. However, content may still contain errors or inaccuracies, and we recommend independent verification.
To report a problem or provide feedback, click here. Feedback may be used to improve accuracy in accordance with our Privacy Policy. -
Challenge
Build the foundational data and input cleanup
This step establishes the shared data and text-cleaning behavior that the rest of the application depends on. Before conditionals can work reliably, the program needs a stable list of supported choices and a consistent way to interpret user input.
-
Challenge
Turn comparisons into potion rules
This step is where the core decision-making logic comes to life. You will write focused helper functions that compare ingredients, detect special pairings, and convert those checks into the final outcome message shown to the user.
-
Challenge
Add validation, imports, and output formatting
This step makes the application feel more realistic. You will guard against unsupported input, import Python's
randommodule for dynamic behavior, and add a formatting helper so the round output is easier to read. -
Challenge
Complete the round flow and run the CLI
This final hands-on step connects all the pieces you have built so far into a complete user experience. You will assemble a single round from normalized input through final messaging, then wire that flow into the
mainfunction so the application can run from the Terminal tab. Once you've finished the tasks, it's time to test your work!In the Terminal, run the game with the following command:
python3 -m app.brew_gameWhen prompted, enter one of the supported ingredients:
Choose herb, crystal, or mushroom:For example:
Choose herb, crystal, or mushroom: herb Cauldron base: crystal Your ingredient: herb The mixture fizzles.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.