Day 13 Task: Basics of Python

Day 13 Task: Basics of Python

#Day13 of 90DaysofDevOps Challenge

Table of contents

No heading

No headings in the article.

Let's Start with the Basics of Python as this is also important for DevOps engineers to build the logic and Programs.

What is Python?

  • Python is an Open source, general-purpose, high-level, and object-oriented programming language.

  • It was created by Guido van Rossum

  • Python consists of vast libraries and various frameworks like Django, Tensorflow, Flask, Pandas, Keras etc.

How to Install Python?

You can install Python in your System whether it is Windows, MacOS, ubuntu, centos etc. Below are the links for the installation:

Task1:

  1. Install Python in your respective OS, and check the version

    Windows:

    1. Visit the official Python website at https://www.python.org/downloads/.

    2. Download the latest version of Python for Windows.

    3. Run the installer and select the option to install Python.

    4. Make sure to check the box that says "Add Python to PATH" during the installation process.

    5. Follow the prompts and complete the installation.

Once installed, you can check the version of Python by opening the Command Prompt and typing the following command:

    python --version

Mac:

  1. Open a web browser and go to the official Python website at https://www.python.org/downloads/.

  2. Download the latest version of Python for macOS.

  3. Run the installer package.

  4. Follow the prompts and complete the installation.

To check the version of Python, open the Terminal and type the following command:

    python3 --version

Linux (Ubuntu):

  1. Open a terminal.

  2. Update the package index using the following command:

    sudo apt update
  1. Install Python by running the following command:
    sudo apt install python3
  1. Once the installation is complete, you can check the version of Python by typing the following command:
    python3 --version

Please note that the specific commands and steps may vary depending on your operating system version or distribution.

  1. Read about different Data Types in Python.

    In programming, the data type is an important concept.

    Variables can store data of different types, and different types can do different things.

    Python has the following data types built-in by default, in these categories:

    Text Type:

    str

    Numeric Types:

    int, float, complex

    Sequence Types:

    list, tuple, range

    Mapping Type:

    dict

    Set Types:

    set, frozenset

    Boolean Type:

    bool

    Binary Types:

    bytes, bytearray, memoryview

    None Type:

    NoneType

  1. Numeric Types:

    • int: Integer values like 1, 2, -3, etc.

    • float: Floating-point numbers with decimal points like 3.14, -2.5, etc.

    • complex: Complex numbers in the form of a + bj, where a and b are real numbers and j is the imaginary unit.

  2. Boolean Type:

    • bool: Represents boolean values, either True or False.
  3. Sequence Types:

    • str: Represents a sequence of characters, such as "Hello, World!".

    • list: An ordered collection of items, enclosed in square brackets ([]), e.g., [1, 2, 3].

    • tuple: Similar to a list, but enclosed in parentheses (()), and its elements are immutable (cannot be changed).

  4. Mapping Type:

    • dict: Represents a collection of key-value pairs enclosed in curly braces ({}) or created using the dict() constructor.
  5. Set Types:

    • set: An unordered collection of unique elements enclosed in curly braces ({}).

    • frozenset: Similar to a set, but its elements are immutable.

  6. None Type:

    • None: Represents the absence of a value or a null value.
ย