# GitHub Copilot & ChatGPT for Developers

**1 Introduction to ChatGPT (Developer Perspective)**

**What ChatGPT Can Do**

* Generate code from natural language
    
* Explain unfamiliar code
    
* Debug errors
    
* Refactor code
    
* Write tests & documentation
    

**What ChatGPT Cannot Reliably Do**

* Guarantee correctness
    
* Replace design thinking
    
* Understand hidden system context
    

📌 Tip: Emphasize **AI as a co-pilot, not an autopilot**

---

**2 Prompt Engineering for Developers**

**Prompt Types**

* **Instructional**: “Write a Python function to…”
    
* **Contextual**: “You are a backend engineer…”
    
* **Iterative**: “Improve the previous solution by…”
    
* **Constraint-based**: “Use only standard libraries…”
    

**Prompt Components**

* Role
    
* Task
    
* Context
    
* Constraints
    
* Output format
    

**Bad Prompt**

Write code to sort data

Prompt 2: Write SQL query to select 10 records from products table

**Good Prompt**

You are a Python developer. Write a function to sort a list of dictionaries by price in descending order. Handle missing keys gracefully.

Ask questions before starting the work. do not assume anything implicitly

---

**3 Hands-on: ChatGPT Coding Scenarios**

**Activity 1: Code Generation**

* Ask ChatGPT to:
    
    * Create a number guessing game
        
    * Build a REST API skeleton
        
    * Write a data validation function
        

**Activity 2: Code Explanation**

* Paste unfamiliar code
    

def process\_numbers(numbers):

    result = \[\]

    for n in numbers:

        if n % 2 == 0:

            result.append(n \*\* 2)

        else:

            result.append(n \*\* 3)

    return result

Explain this Python code line by line.

Assume I am a beginner and also explain why this logic might be useful.

**Activity 3: Debugging**

def calculate\_average(numbers):

    total = 0

    for i in range(len(numbers)):

        total = total + numbers\[i\]

    average = total / len(numbers)

    return avg

The following Python code throws an error.

Identify the issue, explain why it happens, and provide the corrected code.

***Follow-up prompt***

Improve this code using Python best practices.

·  ChatGPT as a **code explainer**

·  ChatGPT as a **debugging assistant**

---

**4 Free ChatGPT Alternatives**

* Google Gemini – reasoning + search
    
* Microsoft Copilot – enterprise & M365
    
* Claude – long context, safer responses
    

---

**5 Introduction to GitHub Copilot**

**What Copilot Is**

* AI pair programmer inside IDE
    
* Context-aware code completion
    

**Capabilities**

* Inline suggestions
    
* Comment-based prompting
    
* Copilot Chat
    
* Test generation
    

---

**6 Prompting with GitHub Copilot**

**Inline Prompting**

\# Write a Python function to check if a number is prime

**Comment-Driven Design**

\# Game: Player vs Computer

\# Rules:

\# - Guess a number between 1 and 100

\# - Provide hints

---

**7 Rules for Effective Prompts (Copilot & ChatGPT)**

* Be explicit
    
* Add constraints
    
* Describe intent, not syntax
    
* Iterate, don’t expect perfection
    
* Always **review output**
    

---

**8 Hands-on: Game Scenario (Language-agnostic)**

**Task**

* Build a simple game:
    
    * Guess the number / Tic-Tac-Toe / Dice game
        
* Use:
    
    * ChatGPT for logic
        
    * Copilot for implementation
        

**Outcome**  
Participants experience:

* AI-assisted design
    
* Faster coding
    
* Reduced boilerplate work
    

---

**9 Module 1 Takeaways**

* Prompt quality = output quality
    
* ChatGPT excels at reasoning & explanation
    
* GitHub Copilot excels at **in-IDE productivity**
    
* Developers remain accountable for correctness
