How to run python code?

You can run python code in many ways. Listing the set of popular options below. I am assuming you have installed Anaconda for python on your system, hence all below options will be available.

  1. From command prompt
  2. IDLE
  3. Spyder IDE
  4. Pycharm IDE
  5. Jupyter Notebook

Command Prompt

  1. Open command prompt
  2. type python
  3. Python prompt (>>>) will appear
  4. Start typing your commands there

Python in Command Prompt
Python in Command Prompt


IDLE

This a a slightly better place to write python commands! This offers features like autocompletion of command and help for libraries.

  1. Type IDLE to find the program in the start menu
  2. Click on the IDLE icon
  3. A white window will appear with python prompt (>>>)
  4. Start typing your commands there

Python IDLE in windows

Python IDLE in Windows


Spyder IDE

  1. Type Spyder to find the program in the start menu
  2. Click on the Spyder icon
  3. Spyder application will open
  4. Start typing your commands in the left side panel
  5. More information about navigating Spyder IDE can be found here

Python Spyder IDE
Python Spyder IDE


Pycharm IDE

  1. Type pycharm in the start menu to find the program
  2. Click on the pycharm icon
  3. A black window will open
  4. Start typing your commands in the left side panel
  5. More information about Pycharm can be found here

Python Pycharm IDE
Python Pycharm IDE


Jupyter Notebook

  1. Type ‘jupyter notebook’ in start menu to find the program
  2. Click on the jupyter notebook icon
  3. A black window will appear, which will start the server for jupyter on your localhost
  4. Jupyter notebook will open inside a browser with URL: “http://localhost:8888/tree”
  5. Click on the drop down on the right hand side called “New”
  6. Select “Python 3” from the drop down
  7. A new webpage will open as “Untitled”
  8. Start typing your commands in the cells.
  9. To execute the cells, use the “run” button from the top menu
  10. More information about Jupyter notebooks can be found here

Opening a new Python script in Jupyter Notebook
Opening a new Python script in Jupyter Notebook

Python Jupyter Notebook

Personally I prefer using Jupyter notebook among all these options. The reasons are easy code sharing, collaboration between team members, and cloud based development.

Author Details
Lead Data Scientist
Farukh is an innovator in solving industry problems using Artificial intelligence. His expertise is backed with 10 years of industry experience. Being a senior data scientist he is responsible for designing the AI/ML solution to provide maximum gains for the clients. As a thought leader, his focus is on solving the key business problems of the CPG Industry. He has worked across different domains like Telecom, Insurance, and Logistics. He has worked with global tech leaders including Infosys, IBM, and Persistent systems. His passion to teach inspired him to create this website!

Leave a Reply!

Your email address will not be published. Required fields are marked *