Are you ready to embark on an exciting journey into the world of Python programming? In the new Cisco Networking Academy course for DevNet Associate, the first chapter sets the foundation for your success. But fret not, you don't need to be a programming expert or a Linux guru to excel in this course. All you need is a basic understanding of Python and familiarity with the Linux terminal.

To ensure you have the essential knowledge, I recommend the book "Python Crash Course, Second Edition" by Eric Matthes. This resource presents Python programming in a clear and concise manner, focusing on the fundamentals without overwhelming you with unnecessary complexities. It's the perfect companion to grasp the core concepts of Python programming.

In our classes, we prefer using the Linux Mint virtual machine to provide a consistent platform for everyone. By utilizing this virtual machine, we create an environment that simplifies the learning process and ensures a level playing field for all participants. To get started, you can download Linux Mint from the official Linux Mint website. Opt for the 64-bit Mate version as the ISO file, which serves as the image file for the Linux operating system.

Next, you'll need to install VirtualBox, a virtualization software that enables you to run Linux Mint as a virtual machine. If you prefer VMware Workstation, feel free to use it instead. Once you've installed VirtualBox, don't forget to install the corresponding extension pack to enhance its functionality. You can find the extension pack on the VirtualBox website.

After installing VirtualBox and obtaining the Linux Mint ISO file, it's time to create a new virtual machine. In the VirtualBox settings, set the operating system to "Linux 64-bit" and select "Ubuntu" as the nearest parent distribution since Linux Mint is based on Ubuntu. Allocate a suitable amount of virtual RAM, ideally between two to four gigabytes, depending on your system's capabilities. Set the virtual hard drive size to around 15 gigabytes to accommodate the Linux Mint installation.

To initiate the installation process, point the virtual CD/DVD drive to the Linux Mint ISO image file within the VirtualBox settings. When you start the virtual machine for the first time, you'll be prompted to install Linux Mint on the desktop. Follow the instructions to complete the installation, and soon you'll have a fully functional Linux Mint virtual machine at your disposal.

These initial steps are crucial for preparing your environment to delve into the fascinating world of Python programming. By laying this foundation, you'll be equipped to tackle the upcoming chapters with confidence. Stay tuned for more insights and practical guidance as we explore the intricacies of Python programming in the DevNet Associate course. Remember, the key to success is mastering the basics. So, let's embark on this rewarding journey together as we unlock the potential of Python programming for DevNet Associates.

Setting Up Python in Linux Mint: A Step-by-Step Guide

Congratulations on successfully installing Linux Mint as a virtual machine! Now it's time to dive into the world of Python programming. In this guide, I'll walk you through the necessary steps to get Python up and running smoothly on your Linux Mint environment.

To start, once you've installed Linux Mint, you need to double-click the icon on the desktop that says "Install the operating system." This will initiate the installation process, allowing you to set up Linux Mint on the virtual hard drive you created earlier. During the installation, you'll be prompted to set a username, password, language, keyboard layout, and other preferences.

Getting Started with Python Scripting in Linux Mint

Now that you have your Linux Mint virtual machine set up and Python installed, it's time to start writing your first Python script. In this section, I'll guide you through the initial steps outlined in Chapter 1 of the "Python Crash Course" book to help you get started with Python scripting.

To begin, open a terminal by clicking on the terminal icon in the quick launch bar at the bottom of the screen. Clear the terminal by entering the "clear" command to provide a clean workspace for your script.

The first task is to create a directory to store your Python work. Enter the command "mkdir python_work" to create a directory named "python_work". Change into this directory using the "cd python_work" command.

Now, let's create a Python script using the nano text editor. Enter the command "nano hello_world.py" to create a new file named "hello_world.py" with the .py file extension, indicating that it's a Python script.

Once the nano text editor opens, begin by adding a shebang line at the top of the file. Enter "#!/usr/bin/python3" to specify the path to the Python 3 interpreter. This line ensures that the script is executed using Python 3.

Next, let's write a simple "print" statement. Enter "print('My Python script')" inside the script file. This line will output the string "My Python script" when the script is run.

To save and exit the nano text editor, press Ctrl+X, followed by Y to confirm the save, and then press Enter.

Now, you can run the Python script using the command "python3 hello_world.py". The script will execute, and you should see the output "My Python script" displayed in the terminal.

If you need to make changes to your script, reopen it with the nano text editor by using the "nano hello_world.py" command. After making your modifications, save and exit the editor using the same Ctrl+X, Y, and Enter sequence.

In addition to creating your first Python script, it's also essential to keep your software packages up to date. To update your package repository list, enter the command "sudo apt-get update" and provide your password when prompted. This command will update the list of available software packages for installation.

To enhance your Python scripting experience, you may want to install a text editor with more advanced features. In the book, "Python Crash Course" recommends installing the Sublime Text editor. To do so, enter the command "sudo apt-get install sublime-text". However, feel free to use any text editor you prefer.

With these steps completed, you've successfully started your Python scripting journey in Linux Mint. Now it's time to explore the endless possibilities that Python offers and continue learning and building your skills. Stay tuned for more in-depth tutorials and practical exercises as we delve further into Python scripting on Linux Mint.

Running Python Scripts with Sublime Text in Linux Mint

Now that you have installed the Sublime Text editor, let's explore how to run your Python scripts using this powerful text editor. In this section, we'll cover the steps required to configure Sublime Text for executing Python scripts seamlessly.

To launch Sublime Text, go to the "Start" menu, navigate to "All Applications," select "Programming," and choose "Sublime Text." The Sublime Text editor will open, providing you with a sophisticated environment for writing and editing your Python scripts.

Running Python Scripts with Sublime Text in Linux Mint

Now that you have installed the Sublime Text editor, let's explore how to run your Python scripts using this powerful text editor. In this section, we'll cover the steps required to configure Sublime Text for executing Python scripts seamlessly.

To launch Sublime Text, go to the "Start" menu, navigate to "All Applications," select "Programming," and choose "Sublime Text." The Sublime Text editor will open, providing you with a sophisticated environment for writing and editing your Python scripts.

Next, we need to open our Python script in Sublime Text. To do this, click on "File" in the top menu, select "Open," and browse to the location of your script. In this example, we'll navigate to the "home/dan/python_work" directory and select the "hello_world.py" script.

Once the script is opened in Sublime Text, we can proceed to configure the build system to run our Python script seamlessly. Go to the "Tools" menu, select "Build System," and choose "New Build System." A new build file will open where we can define our custom build system.

In the build file, make the following modifications: change "shell command" to "cmd" and update the content within the brackets. Replace it with "python3 -u" (without the quotes) followed by "$file" (also without the quotes). This ensures that the Python 3 interpreter runs our script.

Save the build file by selecting "Save" from the "File" menu. Name the file "python3.sublime-build" to indicate that it's the build configuration for Python 3. Close the build file.

Now, when you go to the "Tools" menu, you'll see "Build System" listed, and under that, you should find "Python 3." Selecting "Python 3" sets the build system to use the Python 3 interpreter for executing your scripts.

To run your Python script within Sublime Text, you have two options. First, you can use the keyboard shortcut Ctrl+B or select "Tools" and then "Build" from the top menu. This will execute the script, and the output will be displayed in the Sublime Text console.

Alternatively, you can run the script directly from the terminal by navigating to the script's directory using the "cd" command and then executing the script with the command "python3 script_name.py". This allows you to run the script independently of Sublime Text.

By following these steps, you have successfully set up Sublime Text as your Python scripting environment in Linux Mint. Now you can write, edit, and execute your Python scripts effortlessly using Sublime Text's advanced features and the Python 3 interpreter.

In conclusion, Chapter 1 has focused on setting up your development environment, enabling you to begin your Python journey smoothly. In the subsequent chapters, we'll dive deeper into Python programming concepts and explore the vast possibilities of this versatile language.

Comments

Leave a comment