Introduction to Python

Last Updated : 9th August 2025


Python ek high-level, interpreted, aur general-purpose programming language hai.

Key Points of Python:

  • Develop in 1991 by Guido van Rossum
  • Open Source (free to use)
  • File Extension: .py
  • Dynamic Typed Language
  • Cross-platform (Windows, Mac, Linux)
  • Huge Community Support
  • Libraries for everything (data science, AI, web, automation, etc.)

How to Run Python

1. Use any Online Editor


2. Install Python


3. Use Code Editor (Vs Code)


Variables And Keywords

1. Variables 📥

  • Variables are containers for storing data values.
  • To declare a variable in Python, you use the var_name = value syntax, e.g. a = 10
  • Rules for variable names:
    • Must start with a letter or an underscore
    • Can contain letters, numbers, and underscores
    • Cannot start with a number
    • Case-sensitive (a and A are different variables)
    • Spaces are not allowed
    • Reserved keywords cannot be used as variable names
    • e.g a=10 ✅, 1a=10 ❌, __= 2 0 ✅, a1=10 ✅, 10=10 ❌, first Value = 10 ❌, for = 10 ❌ 'for' is a keyword, first number = 20 ❌
  • Naming Conventions:
    • Use descriptive names (e.g. user_name, user_age, user_height)
    • Avoid abbreviations (e.g. u_name, u_age, u_height)
    • Avoid Single Letter Variables (e.g. a, b, c)
  • Naming Standard:
    • Lowercase (e.g. username, userage, userheight)
    • Uppercase (e.g. USERNAME, USERAGE, USERHEIGHT)
    • CamelCase (e.g. userName, userAge, userHeight)
    • PascalCase (e.g. UserName, UserAge, UserHeight)
    • snake_case (e.g. user_name, user_age, user_height)

2. Keywords

  • Predefined words in Python.
  • It is just like Predefined variables.
  • e.g. True, False, None,print, input, etc.

Comments

Used to explain the code. It is invisible to the interpreter i.e it is not executed,python ignores it.

1. Single Line Comment

  • Use # for single line comments.
  • e.g. # This is a single line comment

2. Multi Line Comment (Doc String)

  • Use """ for multi line comments.
  • e.g. """Hello Reader!
    This is a multi line comment"""