Python code in Jupyter notebook

Python code in Jupyter notebook | Using Notepad++

How we can run python file in Jupyter notebook?

In this, when we want to run python code that is written in any editor like notepad,notepad++ etc.

Firstly, I will tell you loading the code and running the python file in ipython.

How to load code in Jupyter notebook?

You can load code from file in jupyter notebook by writing this code in ipython –


If you have kept your file in different location you will get this type of error-

ValueError: ‘’ was not found in history, as a file, url, nor in the user namespace.

This file should be in current working directory. It is better to kept the file where you are using your Jupyter notebook.

How to run the python file in Jupyter notebook?

You can run the python file by writing this code-

I am giving one example so you can easily understood this concept.

I am creating factorial python code on notepad++ and save as

For Example-

Consider an example for a factorial of a number in python.

n=input("Enter number:")
for i in range(1,int(n)+1):
print("Factorial is :",fact)

I also kept screenshot for code written in python for better understanding.

NOTE — In windows, when you clicks Shift+Enter key — move to next cell with result (output of your code).

To load code in jupyter-


To run the python file in jupyter-


This example, i input a number: 5 and got result 120.

In mathematics, 5!=1*2*3*4*5=120.

I hope you have understood the running the code in ipython. Now, you can start coding on this platform and also used for data analysis with the help of python.

Application developer|Technical blogger|Youtuber(MASTERMIND CODER)|owner at