Python Execution

 In Python, there are several ways to execute code, depending on your needs and the context in which you are working.

 Here are the primary execution types: 

i. Interactive Mode

ii. Script Mode


1. Interactive Mode (Python Shell or REPL - Read-Eval-Print Loop):

   Interactive mode allows you to execute Python code one line at a time and immediately see the results. You can open an interactive Python shell by typing python in your terminal or command prompt.

   Example:



   Note:  Make sure you have Python installed on your computer. You can check if Python is installed by typing python or python3 and hitting Enter. If it's installed, you'll enter the Python interactive shell.


2. Script Mode:

   In script mode, you write Python code in a separate file with a .py extension and execute the entire script. You run a Python script from the command line using python script_name.py.

   Example:



                       Command to execute:

                                                           open  your terminal and type

                                                            python HelloWorld.py

                                                            HelloWorld.py is the filename with python extension

     Note: Here i'm using vscode editor          

These are some of the common ways to execute Python code, and the choice of execution type depends on your specific requirements and the nature of your project or task.

Popular posts from this blog

Python Variables

Python Type Checking

Operators in Python