DEV Community

Cover image for Python - Interactive Console
Sm0ke
Sm0ke

Posted on • Originally published at blog.appseed.us

Python - Interactive Console

Happy new year!

This article is a short introduction to Python shell, the Interactive console where we can fully interact with Python magic. For newcomers, Python is a popular language that we can use to code many types of projects: web apps, games, OS system programming, or even data analytics and machine learning. Once Python is properly installed and accessible in the terminal windows, we can start writing code using the Python Interactive Console.

Thanks for reading!


$ python --version
Python 3.8.4       <--- The output
Enter fullscreen mode Exit fullscreen mode

In case the above command returns an error, probably Python is not installed or not present in the execution PATH of your operating system.


πŸ‘‰ Python - Launch the console

$ python
Python 3.8.4 [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Working into the Python Console

$ python
>>>       
>>> my_name = 'Bill'    # define a variable
>>> my_name             # uses the variable 
'Bill'
>>>
>>> 1 + 2               # return the addition of two numbers 
3 
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Python Console - Use Modules

Before using any module, we need to install it first via PIP, the official package manager for Python.

$ pip install webbrowser
Enter fullscreen mode Exit fullscreen mode

The above command will install webbrowser module, a popular web browser controller.

$ python                                  # start the Python Console
>>> 
>>> import webbrowser                     # import the module
>>> webbrowser.open('https://appseed.us') # open a web page
True
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Python Console - Exit

$ python        # start the console
>>> 
>>> 1 + 1       # coding stuff     
2 
>>>
>>> quit()      # exit from the console   
Enter fullscreen mode Exit fullscreen mode

Thanks for reading! For more resources, feel free to access:

Discussion (2)

Collapse
limitcracker profile image
Ioannis Gyftakis

Hi, do you know how to approach making an online interactive coding editor for python?

Collapse
sm0ke profile image
Sm0ke Author

Nope, sorry