How To Run Python Program In Terminal

Chapter: Python Last Updated: 14-05-2023 12:10:04 UTC

Program:

            /* ............... START ............... */
                ''' Once you're in the correct directory, you can run the Python program using the 
  python command followed by the name of the Python file. '''

python my_program.py

''' If you have both Python 2 and Python 3 installed, you may need to use python3 instead of python 
 to specify the Python 3 interpreter explicitly: '''

python3 my_program.py

                /* ............... END ............... */
        

Notes:

  • To run a Python program in the terminal, you can follow these steps:
  • Open a terminal or command prompt on your computer.Navigate to the directory where your Python program is located. You can use the cd command (change directory) to move to the appropriate location.For example, if your Python program is in the Documents folder and you're using a Unix-based system (such as macOS or Linux), you can use the following command to navigate to the directory:
  • ~ cd Documents
  • Once you're in the correct directory, you can run the Python program using the python command followed by the name of the Python file.For example, if your Python program is named my_program.py, you can run it with the following command:
  • ~ python my_program.py
  • If you have both Python 2 and Python 3 installed, you may need to use python3 instead of python to specify the Python 3 interpreter explicitly:
  • ~python3 my_program.py
  • Press the Enter key, and the Python program will run in the terminal. The output, if any, will be displayed in the terminal window.
  • Please note that you need to have Python installed on your computer and properly set up in your system's PATH variable for the python or python3 command to be recognized.

Tags

How to run Python script in Linux #How To Run Python Program In Terminal #How to run a Python script

Similar Programs Chapter Last Updated
Python Program To Check Whether Element Present In Set Or Not Example Python 04-10-2023
Python Program To Find Maximum And Minimum Number In A Set Python 04-10-2023
Python Program To Check Symmetric Matrix Python 04-10-2023
Python Program To Find Subsets Of A Set Python 04-10-2023
Python Program To Find Power Set Of A Set Python 04-10-2023
Remove All Duplicates From List Python Python 04-10-2023
Python Program To Find Symmetric Difference Of Two Sets Python 27-09-2023
Python Program To Find Common Item From Two Set Python 27-09-2023
Python Program To Get Unique Values From A List Python 27-09-2023
Python Encode And Decode String With Key Python 24-09-2023
Python Simple Encrypt Decrypt String Python 24-09-2023
Python Format String To Specific Length Python 24-09-2023
Python Code To Check If String Contains Substring Python 24-09-2023
Python Program To Find Most Repeated Word In A String Python 23-09-2023
Split String Into Words Python Python 23-09-2023
Remove All Punctuation Python Python 23-09-2023
Python Program To Reverse An Array Python 23-09-2023
Python Program To Find Number Of Palindrome In A String Python 23-09-2023
Python Program To Find Longest Common Substring Python 23-09-2023
Python Program To Find Number Of Days In A Given Month And Year Python 22-09-2023
Python Program To Calculate Age Of A Person Python 22-09-2023
Python Code To Get Day Of Week Python 22-09-2023
Python Convert String To Date Without Time Python 22-09-2023
Python Program To Print Current Date And Time In Format dd/mm/yyyy Python 22-09-2023
Python Program To Find Working Days In A Month Python 19-09-2023
Python Code To Change Date Format Python 16-09-2023
Python Program To Calculate Number Of Days Between Two Dates Python 16-09-2023
Python Program To Calculate Age In Years Months And Days Python 16-09-2023
Python Program To Schedule A Job To Run After A Certain Amount Of Time Python 10-08-2023
Python Program To Schedule A Job To Run Randomly Once A Day Python 10-08-2023

1 2 3 4