Tutorial Material

Running Python

Share to

To run Python, there are many ways you can do it. You can use a shell, terminal or use an IDE (Integrated Development Environment). Below are the steps to run Python in the easiest way.

Note: You can also run and edit Python code directly on this website in every code snippet interactively! Look for the "Run" button on the code blocks.

Linux

  1. Open terminal CTRL+ALT+T
  2. Type python then you will enter the Python shell.
  3. Write your Python script, example: print("Welcome to Python"). If done press the ENTER key, and the Python script will be executed.
  4. To exit from Python shell type exit()

or

  1. Use a text editor, for example gedit.
  2. Create a new file, and type your python script, example: print("Welcome to Python").
  3. Save As with extension .py (example: print.py).
  4. Run file using Terminal.
  5. Open terminal CTRL+ALT+T.
  6. Enter the directory where your Python file is saved (example: cd /Users/admin/Desktop/).
  7. Run the Python script using python followed by the filename (example: python print.py).
  8. Your Python script will be executed/run.

Windows

Using Shell

  1. Open IDLE (python shell in windows), you can search for it in the START button.
  2. Write your Python script, example: print("Welcome to Python"). If done press the ENTER key, and the Python script will be executed.

Python Shell Windows

  1. To exit from Python shell type exit()

Using Script Editor

  1. To run a script saved in a file, open IDLE (python shell in windows), you can search for it in the START button.
  2. Click menu File - New File
  3. Write Python script on the window that appears, example:
print("Learn Python")
print("at belajarpython.com")
  1. Save script via menu File - Save
  2. Run program by clicking menu Run - Run Module

Python Editor Windows

Mac OS

  1. Open terminal.
  2. Type python then you will enter the Python shell.
  3. Write your Python script, example: print("Welcome to Python"). If done press the ENTER key, and the Python script will be executed.
  4. To exit from Python shell type exit()

or

  1. Use a text editor.
  2. Create a new file, and type your python script, example: print("Welcome to Python").
  3. Save As with extension .py (example: print.py).
  4. Run file using Terminal.
  5. Open terminal CTRL+ALT+T
  6. Enter the directory where your Python file is saved (example: cd /Users/admin/Desktop/).
  7. Run the Python script using python followed by the filename (example: python print.py).
  8. Your Python script will be executed/run.

Edit this tutorial

Belajarpython x DevMode Community
OFFICIAL COMMUNITY

Gabung Komunitas Developer & Kreator Digital

Dapatkan teman coding, sharing project, networking dengan expert, dan update teknologi terbaru.

Bebas spam. Unsubscribe kapan saja. DEVMODE Community