27
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
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.
👉 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
👉 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
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
👉 Python Console - Exit
$ python # start the console
>>>
>>> 1 + 1 # coding stuff
2
>>>
>>> quit() # exit from the console
Thanks for reading! For more resources, feel free to access:
- AppSeed for support via eMail and Discord
- Free Dashboards crafted in Flask, Django, and React
27