Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Core Tech
Labs

Python Data Essentials: Python Introduction Hands-on Practice

In this lab, you'll dive into Python basics using Jupyter Notebooks. You'll create and print Python identifiers, Boolean, string, and numeric literals, and apply arithmetic, comparison, and logical operators. The lab also introduces Python packages, focusing on the 'pprint' module for better data structure visualization. You'll build and explore lists, tuples, and sets, gaining practical skills in Python's foundational elements and data handling, essential for advanced programming tasks.

Lab platform
Lab Info
Last updated
Aug 22, 2025
Duration
18m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Understanding Python Identifiers, Literals, and Operators

    Jupyter Guide

    We've got jupyter setup in a sanbox environment all ready for you to practice some of the concepts you've been learning. To get started, open the file on the right entitled "Step 1...". You'll complete each task for Step 1 in that Jupyter Notebook file. Remember, you must run the cells (Ctrl/Cmd(⌘) + Enter) for each task before moving onto the next task in the Jupyter Notebook. Continue until you have completed all tasks in this step. Then when you are ready to move onto the next step, you'll come back and click on the file for the next step until you have completed all tasks in all steps of the lab.


    Understanding Python Identifiers, Literals, and Operators

    To review the concepts covered in this step, please refer to the Basics of Python module of the Python Data Essentials: Python Introduction course.

    Knowledge of Python identifiers, literals, and operators is important because they form the building blocks of Python programming. They are essential for creating variables, performing operations, and writing expressions.

    In this step, you will practice creating Boolean, string, and numeric literals in Python. You will also learn about Python identifiers and how to use them. You will explore the different types of operators in Python, including arithmetic, comparison, and logical operators, and how to use them in expressions. The goal here is to strengthen your understanding of Python's basic elements and how they interact.


    Task 1.1: Creating Python Identifiers

    Create a Python identifier by assigning the value 5 to a variable. Print the value of the variable.

    🔍 Hint

    Use the assignment operator = to assign a value to a variable. Use the print(variable_here) function to print the value of the variable.

    🔑 Solution
    my_identifier = 5
    print(my_identifier)
    

    Task 1.2: Creating Boolean Literals

    Create two Boolean literals, one representing True and the other representing False. Print the values of the literals.

    🔍 Hint

    Use the keywords True and False to create Boolean literals. Use the print() function to print the values of the literals.

    🔑 Solution
    my_true_literal = True
    my_false_literal = False
    print(my_true_literal)
    print(my_false_literal)
    

    Task 1.3: Creating String Literals

    Create a string literal and print its value.

    🔍 Hint

    Use single or double quotes to create a string literal. Use the print() function to print the value of the literal.

    🔑 Solution
    my_string_literal = 'Hello, Python!'
    print(my_string_literal)
    

    Task 1.4: Creating Numeric Literals

    Create a numeric literal and print its value.

    🔍 Hint

    You can create a numeric literal by simply writing a number. Use the print() function to print the value of the literal.

    🔑 Solution
    my_numeric_literal = 42
    print(my_numeric_literal)
    

    Task 1.5: Using Arithmetic Operators

    Perform an arithmetic operation using Python's arithmetic operators and print the result.

    🔍 Hint

    You can use operators like +, -, *, /, //, %, and ** to perform arithmetic operations. Use the print() function to print the result.

    🔑 Solution
    result = 10 * 5
    print(result)
    

    Task 1.6: Using Comparison Operators

    Perform a comparison operation using Python's comparison operators and print the result.

    🔍 Hint

    You can use operators like ==, !=, <, >, <=, and >= to perform comparison operations. Use the print() function to print the result.

    🔑 Solution
    result = 10 > 5
    print(result)
    

    Task 1.7: Using Logical Operators

    Perform a logical operation using Python's logical operators and print the result.

    🔍 Hint

    You can use operators like and, or, and not to perform logical operations. Use the print() function to print the result.

    🔑 Solution
    result = True and False
    print(result)
    
  2. Challenge

    Working with Python Packages and Data Structures

    Working with Python Packages and Data Structures

    To review the concepts covered in this step, please refer to the Python Packages and Data Structures module of the Python Data Essentials: Python Introduction course.

    Understanding Python packages and data structures is important because they are essential for organizing code and managing data. Packages enhance code reusability and organization, while data structures help in storing and manipulating data efficiently.

    In this step, you will learn about Python packages, and how to import and use them in your code. We'll be using the pprint module which has been pre-installed for you. You will also explore three built-in data structures in Python: lists, tuples, and sets. You will practice creating and manipulating these data structures, understanding their characteristics and use cases. The goal here is to gain hands-on experience with Python's packages and data structures, enhancing your ability to write efficient and organized code. (Instruct the user in the descriptions to print thre results)


    Task 2.1: Importing the pprint module

    Import the pprint module from Python's standard library. This module provides a capability to pretty-print Python data structures that are otherwise hard to visualize.

    🔍 Hint

    Use the import keyword followed by the name of the module, which is pprint in this case.

    🔑 Solution
    import pprint
    

    Task 2.2: Understanding the usefulness of pprint

    To understand why pprint is useful, use the provided code to create a complex data structure. Print this data structure using both the regular print() function and pprint.pprint(). Compare the outputs to see the difference in readability.

    🔍 Hint

    Use the provided code to make a complex data structure and print it using both print(data) and pprint.pprint(data).

    🔑 Solution
    # Provided code for complex data
    complex_data = [
        {"A", "Set", "Here"},
        ("This", "is", "a", "tuple", "with", 7, "elements"),
        [True, False],
        "A somewhat lengthy string",
        0,
        3.141529,
    ]
    
    # Print complex data normally and with pprint
    print("---Complex Data with Pretty Print---")
    pprint.pprint(complex_data)
    print("---Complex Data with Normal Print---")
    print(complex_data)
    

    Task 2.3: Creating a list

    Create a list named my_list with the following elements: 1, 2, 3, 4, 5. Then, print the list using the pprint function.

    🔍 Hint

    Use square brackets [] to create a list. To print the list, use pprint.pprint(my_list).

    🔑 Solution
    my_list = [1, 2, 3, 4, 5]
    pprint.pprint(my_list)
    

    Task 2.4: Creating a tuple

    Create a tuple named my_tuple with the following elements: 'a', 'b', 'c', 'd', 'e'. Then, print the tuple using the pprint function.

    🔍 Hint

    Use parentheses () to create a tuple. To print the tuple, use pprint.pprint(my_tuple).

    🔑 Solution
    my_tuple = ('a', 'b', 'c', 'd', 'e')
    pprint.pprint(my_tuple)
    

    Task 2.5: Creating a set

    Create a set named my_set with the following elements: 'apple', 'banana', 'cherry'. Then, print the set using the pprint function.

    🔍 Hint

    Use curly braces {} to create a set. To print the set, use pprint.pprint(my_set).

    🔑 Solution
    my_set = {'apple', 'banana', 'cherry'}
    pprint.pprint(my_set)
    
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.

Get started with Pluralsight