Day-1 | Introduction to Python | Shell Scripting vs Python | Install and Run | #abhishekveeramalla
Table of Contents
Introduction
This tutorial is designed for beginners who want to get started with Python, particularly in the context of DevOps. It covers the basics of Python, compares shell scripting with Python, and guides you through the installation and execution of Python scripts. By the end of this guide, you'll be well-equipped to start your journey in Python programming.
Step 1: Understanding Python and Shell Scripting
- Definition of Python: Python is a high-level programming language known for its readability and versatility. It is widely used in various domains, including DevOps, for automation and scripting.
- Comparison with Shell Scripting:
- Shell scripting is more suited for quick tasks and automation in Unix/Linux environments.
- Python offers more advanced programming features, making it better for complex tasks and larger projects.
- Advantages of Python:
- Easier to read and write.
- Extensive libraries and frameworks available.
- Cross-platform compatibility.
Step 2: Installing Python
-
Download Python:
- Visit the official Python website at python.org.
- Choose the appropriate version for your operating system (Windows, macOS, Linux).
-
Installation Process:
- Run the downloaded installer.
- Ensure to check the box for "Add Python to PATH" during installation.
- Follow the prompts to complete the installation.
Step 3: Verifying the Installation
-
Open Command Line:
- For Windows, use Command Prompt or PowerShell.
- For macOS or Linux, open the Terminal.
-
Check Python Version:
- Enter the following command:
python --version
- If Python is installed correctly, you’ll see the version number displayed.
- Enter the following command:
Step 4: Running Your First Python Script
-
Create a New Python File:
- Use a text editor (like Notepad, VS Code, or Sublime Text) to create a file named
hello.py
.
- Use a text editor (like Notepad, VS Code, or Sublime Text) to create a file named
-
Write Your First Script:
- In the
hello.py
file, add the following code:print("Hello, World!")
- In the
-
Execute the Script:
- Navigate to the directory where your
hello.py
file is located using the command line. - Run the script by typing:
python hello.py
- You should see the output:
Hello, World!
- Navigate to the directory where your
Step 5: Exploring Further Resources
-
GitHub Repository:
- Access the course materials and examples at GitHub Repository.
-
Join Community Groups:
- Engage with peers and ask questions in the Doubts Clearing Group.
-
Follow Additional Learning Platforms:
- Check out other resources and playlists mentioned in the video description for deeper insights into DevOps and Python.
Conclusion
Congratulations on taking your first steps into Python programming! You have learned about the differences between Python and shell scripting, installed Python, and executed your first script. To further enhance your skills, explore the resources provided, and consider joining community groups for support. Happy coding!