- Lab
-
Libraries: If you want this lab, consider one of these libraries.
Strings and Console I/O in Python
Complete a beginner-friendly Python CLI that welcomes a book fair visitor, collects text and numeric input, and prints a readable summary. The lab focuses on strings, console input and output, newline formatting, type conversion with int and float, and simple arithmetic inside small reusable functions.
Lab Info
Table of Contents
-
Challenge
Get oriented with the starter project
Welcome to the lab. You will complete a small Python console application that turns a few simple building blocks into a polished interactive workflow. 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
Create static output with strings
This step focuses on the simplest but most important building block in the lab: text. Before a program can become interactive, it needs readable static output, such as titles, welcome lines, and banners.
-
Challenge
Gather text input from the user
With the banner in place, the next phase is interactivity. This step teaches the core idea that user input enters a Python program as text, and that prompt design affects both usability and program structure.
-
Challenge
Parse numeric input and calculate totals
So far, every value gathered from the user has stayed as text. That works well for names and genres, but quantities and prices need a different treatment because the program must do math with them.
-
Challenge
Assemble the final workflow
The last step brings the application together. Up to this point, you have built small focused helpers for title text, prompts, formatting, parsing, and arithmetic. Now that you've finished the application, it's time to test the complete experience from start to finish.
Run the application from the Terminal tab:
python3 app/booth_helper.pyAs you interact with the program, verify that it can:
- Display the book fair banner and welcome message.
- Prompt for a visitor's name and favorite genre.
- Show a personalized message based on the visitor's interests.
- Collect the number of books being purchased and the price per book.
- Calculate the subtotal correctly.
- Print a complete visit summary with all the collected information.
Try a few different inputs and confirm that the final summary reflects the values you entered and that the subtotal is calculated correctly. If everything works as expected, you've successfully completed the lab!
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.