Practical – 147 : Use Command Line and IDE to create and execute a python program

Here’s a simple step-by-step guide to create and execute a Python program using both Command Line and IDE (like VS Code or IDLE):

✅ 1. Using Command Line (Terminal / CMD)

🔹 Step 1: Open Command Line

  • Windows: Press Win + R, type cmd, and hit Enter.
  • Linux/macOS: Open Terminal.

🔹 Step 2: Create a Python File

You can use Notepad or any basic text editor.

  1. Open Notepad.
  2. Write the following code:
  3. print(“Hello from Python using Command Line!”)
  4. Save the file as: hello.py (e.g., on Desktop or any folder)

🔹 Step 3: Run the Program

  1. Open CMD and navigate to the folder:
  2. cd Desktop
  3. Run the file:
  4. python hello.py

✅ Output:

Hello from Python using Command Line!

✅ 2. Using an IDE (VS Code or IDLE)

🔹 Option 1: Using IDLE (comes with Python)

  1. Open IDLE (Search “IDLE” in Start Menu)
  2. Click File → New File
  3. Type:
  4. print(“Hello from Python using IDLE!”)
  5. Save as hello.py
  6. Click Run → Run Module or press F5

✅ Output will appear in the shell.

🔹 Option 2: Using VS Code

  1. Open Visual Studio Code
  2. Install the Python Extension (if not already)
  3. Create a new file: hello.py
  4. Type:
  5. print(“Hello from Python using VS Code!”)
  6. Save the file
  7. Right-click and select Run Python File in Terminal

✅ Output:

Hello from Python using VS Code!