An Introduction to Python

An Introduction to Python

What is Python?

  • Python is a computer language used in various applications It was introduced by Guido van Rossum and is an open-source high-level and object-oriented language

  • Python consists of vast libraries and frameworks like Django, Flask, TensorFlow, PyTorch, Pandas, etc.

How to install Python

For Windows:

Click here to download Python on the Windows operating system

For Linux:

Open Terminal and type the below command to install the python

sudo apt-get update
sudo apt install python3

Task1:

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

     python3 --version
    
  2. Read about different Data Types in Python.

    1. Numeric Types:

      • int: Represents integers, such as 1, -5, or 1000.

      • float: Represents floating-point numbers, which are numbers with a decimal point, like 3.14 or -0.5.

      • complex: Represents complex numbers in the form a + bj, where a and b are floats, and j represents the square root of -1 (e.g., 3 + 2j).

    2. Sequence Types:

      • str: Represents strings of characters, like "Hello, World!" or 'Python'.

      • list: Represents ordered, mutable (changeable) sequences of objects. Lists are created using square brackets, e.g., [1, 2, 3].

      • tuple: Represents ordered, immutable (unchangeable) sequences of objects. Tuples are created using parentheses, e.g., (1, 2, 3).

    3. Mapping Type:

      • dict: Represents a dictionary, which is an unordered collection of key-value pairs. Dictionaries are created using curly braces with key-value pairs, e.g., {'name': 'Alice', 'age': 30}.
    4. Set Types:

      • set: Represents an unordered collection of unique elements. Sets are created using curly braces or the set() constructor, e.g., {1, 2, 3} or set([1, 2, 2, 3]).

      • frozenset: Similar to a set but is immutable. Once created, you cannot modify its contents.

    5. Boolean Type:

      • bool: Represents a Boolean value, which can be either True or False. It's often used for conditional statements and logical operations.
    6. None Type:

      • None: Represents the absence of a value. It is often used to indicate the absence of a return value in functions or methods.
    7. Binary Types:

      • bytes: Represents a sequence of bytes, similar to a string but immutable. It's often used for working with binary data.

      • bytearray: Similar to bytes but mutable.

    8. Iterator Types:

      • iterable: Represents any object capable of returning its elements one at a time. Common iterable types include lists, tuples, dictionaries, and strings.

      • iterator: Represents an object that implements the iterator protocol, allowing you to loop over its elements using a for loop or the next() function.

    9. Custom Classes:

      • Python also allows you to define your own custom data types using classes. You can create objects with attributes and methods to represent complex data structures.

Explore this videos playlist to know more about python

Thank You readers for going through my blog if you love it don't forget to give likes for more such content follow me