How to run a Program in Python
How to run a Program in Python
Writing a program in Python is an easy task, beginners who are ready to kickstart their career in the world of programming can create wonders if they practice basic programs every day.
Python is a simple and easy-to-learn language. The feature that makes it popular is its understandable syntax. So, a person from a non-technical background will also get an idea of what exactly our objective is.
Python is the most preferred language in all the big leading companies which are the tech giants of the IT Industry. Some widely used applications such as YouTube & Dropbox use this language.
Since python is a high-level language there is no need to worry about the details of memory management in the program. Also, it’s interactive in nature so the users can directly execute their chunks of code on the interpreter.
So, the process remains the same, work on building your logic, acquire a good knowledge of the rules that you need to take care of while writing a program, and keep exploring!
Python has a huge library of modules that can provide solutions to complex problems through its in-built components.
Once you have written the code the next step is to execute the program and display the output.
The program we will use to understand the execution is given below-
a=int(input("Enter 1st number: ")) #obtaining first value b=int(input("Enter 2nd number: ")) #obtaining second value c=a+b #performing addition print("Sum of a and b is {}".format(c)) #displaying the result
- Running a program in Command Prompt.
Command Prompt acts as an interpreter in Windows and on specifying the correct path and by using the necessary commands, we can perform the required tasks. Typing 'cmd' in the search area of the taskbar will show the command prompt option and then we can start working on it.
- Open Command Prompt from the taskbar and run your file by specifying the file name.
- Make sure you provide the correct destination of your file.

- Running a program in Python IDLE.
IDLE is Python's Integrated Development & Learning Environment. It works in a similar manner on all the platforms and has this feature of an interactive interpreter.
Moreover, Python IDLE has a shell window and an editor window.
In Python IDLE, each statement is executed and the output is displayed for every line of a program.

- Running a program in Spyder IDE
Spyder IDE is used for scientific programming in python and it is pre-installed in Anaconda Navigator. Packages like NumPy, matplotlib, scipy, and pandas are integrated with this.
It is used by data analysts, scientists, and engineers. It provides advanced editing options and great visualization tools.
- The code given below shows how we can perform addition in python. Once you have written the code. Go to the file and click on 'Save As'. Save your file in the destination folder with .py extension.

- Click on ‘Run’ or F5.

In the output window, you can enter the values and get the output.



- Running a program in Jupyter Notebook
Jupyter Notebook amalgamates all our work in a manner that it looks well-presented and easy to comprehend. Data Science & Machine Learning projects are mostly made on this platform as new components can be easily integrated with the existing ones. Various processes like reading & fetching data from a file, data cleansing & pre-processing, exploratory data analysis, and visualization can be done on Jupyter Notebook.
Jupyter Notebook is that platform where business problems of different domains can be understood and based on the insights, we can report the required solution.
- Open Jupyter Notebook
- Write your code in the provided cells.
- Once you have written the code, Go to ‘File’ and click on ‘Save As’.
- Click on ‘Run’ or ‘Shift+Enter’ to run your code.
- On execution, it will ask you to enter the values.
- On entering the values, the expected output is displayed.



So, these are the four ways of executing a program in Python. Being a computer geek, we must make an effort to understand the functionality of all the four approaches (Running a program on command prompt, Running a program on Python IDLE, Running a program on Spyder IDE, and Running a program on Jupyter Notebook.)