- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Core Tech
Loops and Range in Python
Build a command-line Reading Sprint Tracker that asks a user how many reading sprints they completed, records pages read in each sprint, and prints a readable summary. Along the way, you will practice Python for-loops with range(), including default and custom start-stop-step forms, and reinforce list building, aggregation, and test-driven development.
Lab Info
Table of Contents
-
Challenge
Step 1: Explore the project and the learning path
In this lab, you will build a small Python command-line application that tracks pages read across a series of reading sprints. The project is intentionally simple on the surface so you can focus on one of the most important building blocks in the language: repeating work a specific number of times with
forloops andrange().If you get stuck, you can refer to the provided solution code for each task, available in the
solutionfolder.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
Step 2: Build the foundational range helpers
This step focuses on the most basic and most common use of
range(): creating predictable sequences of numbers for loops and helper functions. Before the application can ask the user for repeated input, it needs clear rules for how sprint positions are represented internally and how they are displayed to the user. -
Challenge
Step 3: Use loops to collect repeated input and labels
This step turns sequence helpers into actual application behavior. Instead of working with isolated number lists, you will now use them to control how many times the program prompts the user and to build data structures that represent a reading session.
-
Challenge
Step 4: Customize range() with start, stop, and step
This step moves beyond the default counting pattern and explores how the third argument to
range()changes a sequence. In practical applications, stepped ranges let you sample every nth record, highlight milestone intervals, or split positions into categories such as odd and even entries. -
Challenge
Step 5: Summarize the session and run the CLI
This final implementation step combines everything you have built so far into a working command-line experience. The data has already been collected; now you will aggregate it, format it, and expose it through one entry-point function. In your Terminal, run
python main.py. The program will prompt you for your name, then ask how many reading sprints you completed, and then ask for the number of pages you read in each sprint one at a time. Once you've entered all your data, it will print a reading summary showing your sprint labels, total pages, average pages per sprint, which sprints fell on even numbers, and which sprints hit a checkpoint interval. Give it a try with 3–5 sprints to see everything in action.
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.