A Beginner's Guide: How to Install Python and Understanding Data Types

A Beginner's Guide: How to Install Python and Understanding Data Types

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.

Ubuntu Installation:

  1. Open a terminal window.

  2. Run the following command to update the package list:

     sudo apt-get update
    
  3. Install Python 3.11 using the following command:

     sudo apt-get install python3.11
    
  4. Verify the installation by typing:

     python3.11 --version
    

Windows Installation:

  1. Visit the official Python website at python.org.

  2. Navigate to the "Downloads" section.

  3. Choose the latest version of Python for Windows and download the installer.

  4. Run the installer and make sure to check the box that says "Add Python to PATH" during installation.

  5. Click "Install Now" to start the installation process.

  6. Once installed, open the command prompt and type python --version to check the installed Python version.

Check Python Version

python --version

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

Exploring Python Data Types

Python supports various data types, each serving a specific purpose. Here are some fundamental data types in Python:

  1. Integers (int): Whole numbers without any decimal points. Example: 5, -12.

  2. Floats (float): Numbers with decimal points or numbers written in scientific notation. Example: 3.14, 2.5e2.

  3. Strings (str): Sequences of characters enclosed in single or double quotes. Example: 'Hello, Python!', "Data Science".

  4. Booleans (bool): Represents the truth values True or False.

  5. Lists (list): Ordered and mutable sequences of elements. Example: [1, 2, 3], ['apple', 'banana', 'orange'].

  6. Tuples (tuple): Ordered and immutable sequences. Example: (1, 2, 3), ('red', 'green', 'blue').

  7. Dictionaries (dict): Unordered collections of key-value pairs. Example: {'name': 'John', 'age': 25}.

Happy coding!