Week 1: Python Fundamentals

Learn Python Basics and Write Simple Scripts

1. Install Python & Jupyter Notebook

Before we start coding, we need to set up our Python environment. Python is a versatile and widely used programming language that allows developers to create software for web applications, data science, artificial intelligence, and more. To get started, follow these steps:

Installing Python

  1. Visit the official Python website: https://www.python.org.
  2. Download the latest version of Python (preferably Python 3.x).
  3. During installation, ensure that you check the box "Add Python to PATH". This will allow you to run Python from any command line interface.
  4. Click "Install Now" and follow the on-screen instructions.
  5. To confirm Python is installed correctly, open Command Prompt (Windows) or Terminal (Mac/Linux) and type: python --version. If installed correctly, it will display the Python version.

Installing Jupyter Notebook

Jupyter Notebook is an interactive environment for writing and executing Python code, making it an excellent tool for beginners.

  1. Open Command Prompt or Terminal.
  2. Install Jupyter using pip: pip install Jupyter.
  3. Once installed, start Jupyter Notebook by running: Jupyter notebook. This will open a web-based notebook interface where you can write and execute Python code interactively.

2. Variables, Data Types, and Operators

Understanding variables and data types is crucial in programming. Python provides various types of data that are used in real-world applications.

Variables

Variables are used to store values that can be reused later. In Python, you don’t need to declare the data type explicitly; Python determines it automatically.


x = 10  # Integer
y = 20.5  # Float
name = "Elias"  # String
is_active = True  # Boolean
        

Real-Life Example: Imagine you're managing a store and need to store data about a product.


product_name = "Laptop"
price = 599.99
in_stock = True
quantity_available = 50
        

Data Types

Advanced Python in Variables and Data Types