Lesson 1: Introduction to Python

🎯 Lesson Objective

By the end of this lesson, you’ll understand:

  • What Python is and where it’s used
  • How to install and run Python
  • Basic syntax, keywords, and comments
  • Writing and running your first Python program

📘 1. What is Python?

Python is a high-level, interpreted programming language known for:

  • Simple and readable syntax
  • Wide use in web development, data science, automation, and AI
  • Huge community and open-source support

Created by: Guido van Rossum (in 1991)
Current versions: Python 3.x (Python 3.12 is latest as of 2025)


💡 2. Why Learn Python?

ReasonDescription
🧠 Easy to LearnClean syntax, beginner-friendly
⚙️ VersatileUsed in data science, AI, web, scripting
📊 LibrariesSupports powerful tools like NumPy, Pandas, Django
💼 CareerIn-demand skill in IT, automation, analytics

⚙️ 3. Setting Up Python

Step 1: Download from https://www.python.org/downloads/
Step 2: Check the box “Add Python to PATH” during installation.
Step 3: Verify installation:

python --version

Output Example:

Python 3.12.2

Step 4: Open an IDE (like VS Code, PyCharm, or IDLE) to start coding.


🧩 4. Your First Python Program

Let’s print your first message 👇

# My first Python program
print("Hello, Python World!")

Output:

Hello, Python World!

🧠 5. Understanding Python Syntax

ConceptExampleDescription
Case SensitiveNamenamePython differentiates between uppercase and lowercase
Indentationif True:
print("Yes")
Uses spaces (not braces) to define code blocks
Comments# This is a commentComments are ignored by Python interpreter
Multiline Comment''' comment '''Used for longer notes or documentation

📊 6. Python Keywords

Reserved words used by Python — you can’t use them as variable names.

Examples:

and, as, assert, break, class, continue, def, del, elif,
else, except, False, finally, for, from, global, if,
import, in, is, lambda, None, not, or, pass, raise,
return, True, try, while, with, yield

Try viewing all Python keywords:

import keyword
print(keyword.kwlist)

💻 7. Interactive Example: Simple Calculator

# Simple addition program
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

result = num1 + num2
print("The sum is:", result)

Example Output:

Enter first number: 10
Enter second number: 5
The sum is: 15

🧪 8. Practice Tasks

Task 1: Write a program to print your name and favorite hobby.
Task 2: Write a Python program that prints:

Welcome to Python Programming!

Task 3: Write a Python program to perform subtraction of two numbers given by the user.
Task 4: Add a comment above each line explaining what it does.


🧱 9. Summary

TopicDescription
Language TypeInterpreted, high-level
Key Functionprint()
Code BlockDefined by indentation
Comments# single line, ''' multi-line '''
First StepInstall and verify Python 3

🏁 10. Assignment (Mini Project)

Project: “Personal Info Display”
Write a small Python script that prints:

  • Your name
  • Your favorite language
  • Your goal for learning Python

Example Output:

My name is Sameer Pasha.
My favorite programming language is Python.
My goal is to become a professional Python developer!

More examples


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *