HOME
ABOUT

Variables and Data Types

Variables and Data Types

Variables

x = 5          # Integer
y = "Hello"    # String
z = 3.14       # Float
is_true = True # Boolean

Basic Data Types

  1. Numbers

    • Integers: 5, -3, 0
    • Floats: 3.14, -0.001
  2. Strings

    name = "Alice"
    greeting = 'Hello World'
    
  3. Booleans

    is_active = True
    is_admin = False
    

Type Checking

type(5)        # <class 'int'>
type("Hello")  # <class 'str'>
type(True)     # <class 'bool'>

Type Conversion

int("5")      # 5
str(42)       # "42"
float("3.14") # 3.14

Related Articles

  • Introduction to Python
  • Setting Up Python Environment
  • Python Syntax Basics
  • Variables and Data Types
  • Operators
  • Input and Output
  • Control Flow: Conditionals
  • Control Flow: Loops
  • Functions
  • Lists and Tuples
  • Dictionaries and Sets
  • String Manipulation
  • How to execute SQL queries (Select, Update, Insert, Delete) effectively using Python?