Day 13 : Basics of Python as this is also important for Devops Engineer

What is Python?

Python, a high-level, interpreted programming language known for its simplicity and readability. Here are the key points:

  • Ease of Learning: Python’s clear and concise syntax makes it particularly beginner-friendly, allowing new developers to quickly grasp programming concepts.

  • Versatility: Python supports various programming paradigms, including procedural, object-oriented, and functional programming, offering flexibility for different project needs.

  • Rich Ecosystem: Python boasts a vast standard library and a thriving community-driven ecosystem of third-party packages, providing solutions for a wide range of applications.

  • Application Areas: Python finds extensive use across diverse fields such as web development, data analysis, artificial intelligence, scientific computing, and automation.

  • Elegance: Python’s syntax is often praised for its elegance and readability, making code maintenance and collaboration easier for developers.

Python was developed by Guido van Rossum and released in 1991, and it has since become a cornerstone in the world of programming.


How to install python in your computer?

Python for Windows installation steps:

Here are the steps to install Python:

  1. Open your favorite browser and search for "Python download." Click on the first search result, which will lead you to python.org.

  2. On the Python website, click on the "Download Python" button to start downloading Python for Windows.

  3. Once the download is complete, run the installer.

  4. In the installation wizard, ensure to check the option "Add Python 3.12 to PATH" and then click on "Customize installation."

  5. Under "Optional Features," ensure all options are selected. Tick the box for "Install launcher for all users (requires admin privileges)." Click on "Next."

  6. Under "Advanced Options," select "Install Python 3.12 for all users." Keep all other settings as default and click on "Install."

  7. If prompted for administrative privileges, click "Yes."

  8. Wait for the installation process to complete. Once done, close the setup.

Now, to verify the installation:

  1. Open Command Prompt by searching for "CMD."

  2. Type "python" and hit enter. You should see the Python version 3.2.2 displayed.

This means Python is successfully installed on your computer.

Python for ubuntu installation steps:

To install Python on Ubuntu, you can follow these steps:

  1. Open a terminal window. You can do this by pressing Ctrl + Alt + T on your keyboard or by searching for "Terminal" in the applications menu.

  2. Update the package index and ensure that you have the latest package lists by running the following command:

     sudo apt update
    
  3. Once the update is complete, you can install Python by running the following command:

     sudo apt install python3
    

    This command will install Python 3, which is the latest version available in the Ubuntu repositories. If you specifically need Python 2 for compatibility reasons, you can install it using sudo apt install python, but note that Python 2 is no longer actively maintained and it's recommended to use Python 3 for new projects.

  4. After the installation is complete, you can verify that Python is installed by typing:

     python3 --version
    

    This command will display the version of Python installed on your system.

  5. Additionally, you may want to install pip, the package installer for Python, by running:

     sudo apt install python3-pip
    

    pip allows you to easily install Python packages from the Python Package Index (PyPI).

That's it! You have successfully installed Python on your Ubuntu system. You can now start using Python by typing python3 in the terminal, or create and run Python scripts as needed.