Console | Jupyter Notebook Tutorial (2026) | Step-by-Step Guide
Console | Jupyter Notebook Tutorial (2026) | Step-by-Step Guide
Below is a step-by-step guide on using the Console in Jupyter Notebook.
The Console in Jupyter Notebook is an interactive Python command environment where you can execute Python code and see the results immediately.
1. Open a Console
In the Jupyter Notebook interface:
- 📌 Click New in the top-right corner.
- 📌 Select Console.
- 📌 Select the kernel Python 3 (ipykernel) and click Select.
A new Console tab will open inside the Jupyter interface.
📌 You can change the Console prompt position to top, bottom, left, or right using the available option in the top-right area of the Console.
2. Run Python Command
📌 Type the following command:
print("Hello World")
📌 Then press Shift + Enter to run the command.
You should see the following output:
Hello World
3. Perform Simple Calculation
📌 Type the following:
10 + 20
📌 Press Shift + Enter.
You will get the following output:
30
4. Create a Variable
📌 Type the following command:
x = 100
You normally won't see an output because you are assigning a value to a variable.
The Console will show the entered command:
x = 100
📌 Now type:
x
You will get:
100
So, the variable x contains the value 100.
📌 To clear Console history, click the Clear Console Cells option.
Example: Create Two Variables
📌 Let's create two variables:
a = 50
b = 25
📌 Then calculate their sum:
a + b
Output:
75
📌 You can also perform other calculations.
Subtraction:
a - b
Output:
25
Multiplication:
a * b
Output:
1250
Division:
a / b
Output:
2.0
5. Working With Text
📌 You can also use strings in the Jupyter Console.
Type the following command:
name = "John"
📌 Then type:
name
Output:
'John'
Or you can use the print() function:
print("My name is", name)
Output:
My name is John
6. Check the Python Version
📌 You can check which Python version your Console is using.
Type the following command:
import sys
📌 Then type:
sys.version
You may see something similar to:
'3.14.6 ...'
This is useful because sometimes Jupyter has multiple Python environments installed.
7. Install & Import a Python Library
📌 For example, you can install and use NumPy.
Install NumPy:
pip install numpy
Then import it:
import numpy as np
📌 Create a NumPy array:
numbers = np.array([10, 20, 30, 40])
📌 Now type:
numbers
Output:
array([10, 20, 30, 40])
📌 You can calculate the average of the numbers:
print(numbers.mean())
Output:
25.0
8. The Console Remembers Previous Commands
📌 This is one of the important features of the Jupyter Console.
Suppose you enter:
name = "John"
Then later enter:
print(name)
Python remembers the name variable. You don't need to create it again.
📌 For example:
name = "John"
age = 25
print(name)
Output:
John
Then:
print(age)
Output:
25
The commands are executed in the same Python kernel/session.
9. Run a Python Program
You can enter multiple lines of Python code in the Console.
For example:
name = "John"
age = 25
if age >= 18:
print(name, "is an adult")
else:
print(name, "is a minor")
The result will be:
John is an adult
10. Difference Between print() and Output
print() is the Python function used to explicitly display something, while output is the result displayed by the command or expression.
Jupyter output: Jupyter automatically displays the value of the last expression.
print() output: Python's print() function explicitly displays the value.
📌 For example, if you type:
10 + 20
10 + 30
Jupyter displays:
40
This happens because Jupyter automatically displays the result of the last expression.
📌 If you type:
print(10 + 20)
print(10 + 30)
You get:
30
40
Here, both results are displayed because the print() function explicitly displays each value.
11. Using the Up Arrow
📌 The Console also makes it easy to access previous commands.
For example, suppose you previously typed:
print("Hello World")
Press the ↑ Up Arrow key.
The previous command may appear again:
print("Hello World")
📌 You can edit the command and press Shift + Enter to run it again.
This is particularly useful when you are experimenting with Python and want to reuse or modify commands you have already entered.
12. Clearing or Restarting the Console
📌 Sometimes you may want to start with a fresh Python environment.
You can restart the kernel/session using the available Kernel Restart options in the Jupyter interface.
When you restart the kernel, variables such as:
x = 100
name = "John"
will be removed from memory.
📌 After restarting, if you enter:
x
You may get an error such as:
NameError: name 'x' is not defined
This happens because x no longer exists in the new Python session.
Conclusion
The Jupyter Notebook Console provides a convenient interactive environment for running Python commands, testing calculations, working with variables, using libraries, and experimenting with Python code.
It is especially useful for beginners because you can execute commands immediately and see the results without creating a complete Python program each time.













Comments
Post a Comment