Understanding Python , Data Types and Data Structures

Understanding Python , Data Types and Data Structures

What is Python?

  • Python is a 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 etc.

How to Install Python?

Windows Installation:

  1. Visit the official Python website: python.org

  2. Download the latest Python installer for Windows.

  3. Run the installer and follow the on-screen instructions.

  4. During installation, ensure to check the option to add Python to PATH.

  5. Once installed, open Command Prompt and type python --version to verify the installation and check the Python version.

Ubuntu Installation:

  1. Open Terminal .

  2. Run the command: to update the package list

    sudo apt-get update

  3. Install Python 3 by running :

    sudo apt-get install python3

  4. After installation, verify Python version by typing python3 --version in the Terminal.

Now python is installed ,let's move into some fundamental concepts such as data types, data structures, and perform hands-on tasks to better understand Lists, Tuples, Sets, and Dictionaries in Python.

1. Data Types :

Data types are classifications of data items that represent the kind of value and operations that can be performed on them. Python provides several built-in data types :

  • Numeric: Integers, Floats, Complex numbers

  • Sequential: Strings, Lists, Tuples

  • Boolean

  • Set

  • Dictionary

2. Data Structures :

Data structures organize and store data in memory to enable efficient access and manipulation. Python offers various data structures :

  • Lists: Ordered collection, mutable

  • Tuple: Ordered collection, immutable

  • Dictionary: Key-value pairs, unordered

  • Set: Unordered collection of unique elements

Difference between List, Tuple, Set and Dictionary :

  1. Lists :

    • Ordered collection

    • Mutable (Elements can be added, removed, or modified)

    • Syntax: my_list = [1, 2, 3, 4]

    • Items in a list do not need to be of the same type .

  2. Tuple :

    • Ordered collection

    • Immutable (Cannot be modified after creation)

    • Syntax: my_tuple = (1, 2, 3, 4)

    • Tuple can also contain elements of various types.

  3. Set :

    • Unordered collection of unique elements

    • Mutable (Elements can be added or removed)

    • Syntax: my_set = {1, 2, 3, 4}

  4. Dictionary :

    It is unordered collection of data values, used to store data values like a map ,Dictionary holds the key:value pair

    Key-value is provided in the dictionary to make it more optimized

Basic Hands-on Tasks :

1. Create Dictionary :

2. Create List of Cloud Service Providers :

Python's versatility in data handling makes it a powerful tool for various applications ranging from data analysis to web development.