Python IDLE/VS Code


To write and run Python programs, you need a Python editor or IDE (Integrated Development Environment). Two commonly used tools for this are:

  • Python IDLE – Comes built-in with Python.

  • Visual Studio Code (VS Code) – A powerful and customizable editor from Microsoft.

Let’s explore both and understand how to set them up.


🐍 Python IDLE

What is IDLE?

IDLE (Integrated Development and Learning Environment) is the default editor that comes with Python installation.

How to Open IDLE:

  1. Install Python from python.org

  2. Open IDLE:

    • On Windows: Search for "IDLE"

    • On macOS/Linux: Run idle in terminal

Features of IDLE:

  • Comes with a Python shell (interactive interpreter)

  • File editor with syntax highlighting

  • Easy to test and run code quickly

  • Good for beginners

Running a Python Script in IDLE:

  1. Open IDLE

  2. Click File > New File

  3. Write your code, e.g.:

    print("Hello from IDLE!")
    
  4. Save the file (e.g., hello.py)

  5. Press F5 or go to Run > Run Module


🧰 Visual Studio Code (VS Code)

What is VS Code?

VS Code is a lightweight and extensible code editor developed by Microsoft. It supports Python through an extension.

Steps to Setup VS Code for Python:

  1. Download and install VS Code

  2. Open VS Code and go to Extensions (Ctrl+Shift+X)

  3. Search and install "Python" extension by Microsoft

  4. Install Python from python.org

  5. Create a new .py file and start writing code:

    print("Hello from VS Code!")
    

Running Python in VS Code:

  • Open a terminal in VS Code: `Ctrl+```

  • Run the script:

    python filename.py
    

VS Code Features:

  • Syntax highlighting

  • IntelliSense (smart code suggestions)

  • Debugging support

  • Git integration

  • Works with many languages


✅ Summary Table

Feature IDLE VS Code
Built-in with Python ✅ Yes ❌ No (needs install)
Beginner Friendly ✅ Very Easy ⚠️ Slight learning curve
Extensions/Add-ons ❌ No ✅ Yes (many)
Debugging Tools Basic Advanced
Recommended For Beginners Intermediate & Advanced

Practice Questions

Q1. Write a Python program to print your name.

Q2. Write and run a program that adds two numbers.

Q3. Create a program that prints today’s date.

Q4. Write a program to calculate area of a rectangle.

Q5. Use input() to take user’s name and print a greeting.

Q6.Write a program that calculates square of a number.

Q7. Write and run a script to reverse a string.

Q8. Create a Python file that checks if a number is even or odd.

Q9. Write a script that prints numbers from 1 to 10.

Q10. Create and run a program to convert Celsius to Fahrenheit.


Go Back Top