## Write And Execute Python Basic Program. - As Consider we have already completed python setup in windows machine in the previous tutorial Now the main basic task is to write a full python code and execute our python first program. ### What is the use of python idle terminal ? you can write your small code on idle terminal and press enter to execute Example: ```python print("I am from terminal ") ``` Output: ``` I am from terminal ``` you can use python idle terminal as a calculator Example: ```python >5+6-7 ``` and press enter to execute you will get the final result in the next line ```python >4 ``` ### How to write a program in idle and run in python? - After the opening of the idle terminal just press **Ctrl+n** to open a notepad like a python text editor. - And write the required code inside the editor. - Now save that file as your required name with **extension.py** Example: ``` filename.py ``` ### How To Run Python file. There are 2 way to run python file 1.Normal - Open Python file in python IDLE. - Now just press **f5** or go running menu option and select **run** to execute the python file. - Now the result will be displayed on your python Shell. 2. Using Terminal - Open command prompt or terminal in your shell. - Go to directory copy path and in command prompt and change command prompt directory using the following command. ```python >cd "directory path" ``` - after changing directory just type ```python dir>python filename.py ``` - Now your required result will be displayed on command prompt ### Error And Solution - if **"python command is not recognized"** occured ### Solution #### Add Python Path To System Variable - Visit following path ``` My Computer >(Right Click) Properties > Advanced System Settings > Environment Variables ``` - Just add the path as C:\Python37 (or wherever you installed python) to **PATH** Variable. - And Also Add python/scripts path to an environment variable.