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.


Python IDLE/VS Code Quiz

Q1: What is IDLE in Python?

A. A game engine
B. A debugger
C. An editor and interpreter
D. A package manager

Q2: Which of these is used to install extensions in VS Code?

A. File Explorer
B. Terminal
C. Command Palette
D. Extensions Panel

Q3: Shortcut key to run a Python program in IDLE?

A. Ctrl + R
B. F5
C. Shift + Enter
D. Alt + R

Q4: Which of these supports Python debugging with breakpoints?

A. Notepad
B. IDLE
C. VS Code
D. Sublime Text

Q5: VS Code is developed by:

A. Apple
B. Google
C. JetBrains
D. Microsoft

Q6: What is the default file extension for Python?

A. .py
B. .python
C. .exe
D. .txt

Q7: Which command runs Python code in terminal?

A. run filename.py
B. py filename.py
C. open filename.py
D. code filename.py

Q8: In IDLE, the interactive shell shows output immediately after:

A. Saving the file
B. Writing code
C. Pressing Enter
D. Closing the file

Q9: VS Code allows code formatting using:

A. Linter
B. Formatter Extension
C. Both
D. None

Q10: Which one is better for large projects?

A. IDLE
B. VS Code
C. Thonny
D. PyCharm

Go Back Top