Python Basics for AI
1. Why Python for AI?
- Python is simple and easy to read (like English).
- It has many libraries for AI and Machine Learning (TensorFlow, PyTorch, scikit-learn).
- Big community support.
Example:
print(5 + 3)
2. Features of Python
- Simple & Easy: Looks like normal English.
- Free & Open-source: Anyone can use it.
- Portable: Works on Windows, Mac, Linux.
- Large Libraries: For math, AI, data, web, etc.
- Interpreted: Runs directly, no compile step.
3. Installing Python
- Visit python.org
- Download the latest version.
- Install like normal software (Next → Next → Finish).
4. Setting up PATH
- PATH tells the computer where Python is kept.
- Tick “Add Python to PATH” during install.
- Then you can run Python from anywhere.
5. Running Python
- Open Command Prompt (CMD).
- Type: python
- Now you can write and run commands.
Example:
print("Hello World")
6. Running Python Script from Command Line
- Save code in a file, e.g., hello.py
print("Hello, I am learning Python")
- Open CMD → go to folder.
- Run: python hello.py
7. Integrated Development Environment (IDE)
- IDE is a special notebook for coding.
- Helps to write, run, debug easily.
- Popular IDEs: IDLE, PyCharm, Jupyter Notebook, VS Code.
Example: In Jupyter, you can write code and see results step by step, useful for AI.