Python - the official website
Python For Beginners - a starting guide
Python Cheatsheet - this site should make you curious
Flask - popular Python web framework
Can be used for things like: (starting from the simple ones)
Basic programming: using strings, adding numbers, open files
Writing system scripts (creating instructions that tell a computer system to “do” something)
Back end (or server-side) web and mobile app development
Desktop apps and software development
Processing big data and performing mathematical computations
The Python can be downloaded from the official website. Choose the installer for your operating system, download, and click a few times. By typing python --version in a terminal window, you should see something like this:
$ python --versionPython 3.7.2
To start using Python we need to open a terminal, type
python and we should be see the python console waiting for input.
>>> a = 'Hello'
Use a variable
>>> a = 'Hello'>>> b = ' World'>>> a + b'Hello World'
Multiply a string
>>> a = 'more '>>> a * 2'more more '
Concatenate a string with a number
>>> a = 'text '>>> b = 1>>> a + bTypeError: can only concatenate str (not "int") to str>>>>>> a + str(b)'text 1'
Python is an open-source software actively supported by a huge ecosystem where programmers expose their work to be reused by others. Flask and Django are just a few examples. The full-index with available packages can be found on PyPI - Python Package Index.
In this section we will write code to extract the title from a web page. To do this, we will reuse two popular libraries putbished on PyPI and use them in the python console to extract the title from
PIP is a official package installer for Python and usually is shipped by Python installer.
$ pip install requests$ pip install BeautifulSoup4
Once the libraries are installed succesfully, we can write code in the Python console.
Just for fun, we can scan and extract the title from
>>> import requests # import the library>>> from bs4 import BeautifulSoup as bs # import the library>>> site = 'https://google.com' # define the website we want to process>>> page = requests.get( site ) # download the page>>> soup = bs(page.content, 'html.parser') # Parse the downloaded page with BeautifulSoup>>> soup.title # Print the title<title>Google</title>
Flask - Available under the BSD license, Flask is another popular Python framework. Inspired by the Sinatra Ruby framework, the microframework requires Jinja2 library and Werkzeug WSGI toolkit.
Django - Full-stack framework Django is one of the most beloved web development frameworks for developing Python applications.
FastAPI - a high performance, easy to learn, ready for production framework