Learnit Training

Practical examples of the Python programming language

In his previous blog trainer André showed that the Python programming language is used all around us. From the photos taken by telescopes to Netflix and Dropbox, Python often plays an important role. In this blog André will show by means of examples how you can use Python in practice.


Modify data in an excel file, add new columns, detect a trend in a series of data, extract errors from data and fill in missing data. You can do all this very easily and quickly with a Python program. In addition, you can save the settings so you can easily reuse it in the same way.

Python packages

Millions of people around the world use Python, a free language with many packages. The packages numpy, pandas and pyplot are important for fast and efficient data processing. With numpy you can quickly edit data, pandas is very suitable for editing tables and with pyplot you can create graphs of the data.

Imagine that a long list of numbers has to be multiplied by a number. You do that in numpy as shown below.

You don't have to multiply every number by 20. It happens all at once.

As you can see below, you can also easily add up lists of numbers.

With pandas you can extract data from an excel file, edit it and write it back again. Let's take as an example a small excel file with profit and loss points in a competition.

We read this data with pandas.

Then we add up the points with pandas.

After this we can write data back to the excel file.

The file looks like this now.

In the last example you can see that it is also easy to make a graph of the table.

The conclusion we can draw from these examples is that you can use Python in many ways to make your work a lot easier. The examples are of course only a small part of the different possibilities Python offers.

Has this blog aroused your interest? Then take a look back at the free webinar of 16 January. André discussed in half an hour how easy it is to use Python in practice. Look him back here!


Python is everywhere

In his previous blog , trainer André showed that in Python you can quickly create a program that does meaningful things: Read and analyze a file, edit data and then create a graph of it. In this blog, the trainer shows where Python is used.

Black hole

The picture above shows a black hole. The image was created by eight telescopes – scattered throughout the world during seventh days in 2017. The telescopes received data from a black hole that was removed from us at 55 million light years.

In the processing of those dates, Python came to look around the corner. Freely accessible and available modules of the programming language, such as Numpy and pandas helped to display the black hole. Click here for more information.


Also streaming service Netflix uses Python. The company uses the programming language to improve the streaming of videos. Python captures which network equipment is active. As a result, the language registers changes in the network, to analyse whether a device is functioning properly.

Furthermore, the streaming service uses Python to ensure that the geographic storage of content is organized so that a video is available as soon as possible for a more used. In This tech blog about Netflix you'll find even more applications for which Python is used.


The popular Dropbox tool uses Python for almost all its features: storage, sharing, Synchronisiatie, permission management and more. The company bought in 2012 Guido van Rossum, creator of Python, away at Google. As a result, Dropbox has since been the best conceivable support in the field of Python.


For Python, several webframeworks have been written. One of the most popular is Django. This framework, originally written for a well-known American newspaper, has become a universally applicable framework.

With Django you simply create a website. Python makes it easy to write code rules and Django will make sure you get structure without much effort. This allows you to maintain your website and expand it for example.

Screenshot of www.nationalgeographic.com, a website built with Django.

A very eye-catching application of Python is the contribution that the programming language has to artificial intelligence (AI). Google is very active in the field of AI and uses Python to control the AI network.

The Python package developed by the company is called Pytorch. Setting up an AI network is not easy. Many other ways of setting up such a network make it necessary to pre-record a large amount of data. Pytorch allows you to set up the network while creating the AI.

In short: More and more companies and organizations use Python, because the language is easy to learn and because there are many modules for Python available to do what they consider important. So if you're interested in your own future, you'll be immersed in Python.

Free webinar

André gave a webinar on Python on 16 July. "I'm going to show how easy Python is to use," said the trainer. Look at him back here.


Python: The language for everyone

Python is a programming language in which everyone can learn programming quickly. With this language you can easily create a small program, develop a website, or create an application. Python is also widely used for artificial intelligence, or for analyzing data. In short Python is everywhere.

It makes sense to know that Python was conceived in 1989 by a Dutchman, Guido van Rossum. Van Rossum worked at the Centre for Mathematics and Informatics in Amsterdam and wanted to write programs in a simple way for a project that was carried out at the Institute.

Growing interest

Although the language was initially only used by a handful of people, the interest increased rapidly. By the expert guidance of Van Rossum the use was only increased. The Dutch polder mentality has ensured that the Python user group is friendly and open, for anyone who wants to work with Python.

Currently, there are thousands of Python files, called modules, that allow the user to write the software he needs. So it's easy in Python to open a text file, to count what words appear in it and how often. Then, in a few Python phrases, the user can extract the most common words and create a chart of them.

Analyzing with Python

Also downloading data from a website can be done in a few Python rules. Python is widely used for data analysis. For example, a company wants to make an analysis of the usefulness of the ads it places on different local media.

To do this, a link must be made between the area where the media appears and the sales in the shops there on the spot. Also now Python can help. In a few lines there is an analysis, and if you want also graphs. If it is useful to put the data in an EXCEL spreadsheet, it costs only one Python rules.

Also for scientific arithmetic and artificial intelligence much use is made of Python. All artificial intelligence platforms are designed to be used by Python and because the language is so easy to learn, many scientists and engineers use it.

The company Tiobe keeps track of which language is widely used. In This ranking, Python is in third place. Most likely Python is going to rise even further.

The conclusion is that when you need programming in your job, Python is the language to learn. In A few days time you can write small but useful programs for example to analyze website data or to monitor the use of network equipment.


Creating dynamic Web sites with JavaScript

JavaScript is a widely used scripting language that is mainly applied to create dynamic Web pages. It is, in other words, a language that allows interaction with visitors and users of a website. JavaScript is used through a browser and is also read in that way (just like CSS and HTML). The code that is present in JavaScript is executed by the browser and it is basically plain text. In this case, a Word-processing tool is not possible to use! However, Editors such as Adobe Dreamweaver, Gedit, or Notepad + + can read this unique code.

The many features of JavaScript

Any Web page that you can interact with, for example, a menu, uses JavaScript. Pages that customize themselves without having to do something for yourself or Instant Search on Google, where all possible search results already appear before you press search: All are examples of applications where JavaScript is used Is. It is therefore a scripting language that is widely applicable.

With this language everything can make even real 3D games (although this is of course a very complicated process)! However, smaller assignments such as building a Mario game, an automatic monitoring website or customizing ads are much simpler to do with JavaScript.

Some important tips when using JavaScript

In managing, writing, and customizing JavaScript, many elements are used to write the code language. The following overview gives some tips to get more out of javascript:

1. Use = = =, not = =

In JavaScript, two ´ equality operators are ´ available, both of which are made up of equality signs, exclamation marks and dashes. It is advisable to use the triple as you will not get any problems when working with different types. If you use = = and! = You will get problems, because the JavaScript engine automatically converts those values.

2. Avoid ' eval '

The ' eval ' function in JavaScript gives you access to the JavaScript compiler as a user. So if you enter a string as a parameter, the compiler will execute it as a JavaScript language, making its execution much slower (and more dangerous)!

3. Place your script at the bottom of the page

When you develop a webpage you want it to load as soon as possible for every visitor. However, if you add an external script, the browser cannot load any further before the complete file is loaded. The consequence? The user needs to wait longer on his page!

If you use JS files with extra functionality (e.g. event handlers for certain buttons), you should load them at the bottom of the page, before the end of the body tag.

More about JavaScript

JavaScript is an indispensable and important language for developing Web pages where visitors have something to do. However, the world of scripting languages is not a simple one, precisely because there are so many different ways to make the visitor experience of a website unique. The more you know here as a beginner, the better you can apply that knowledge to get the best out of your website!

In Our three -day training you get to know JavaScript. The training is a solid foundation for further training on JavaScript-based techniques and toolkits, such as jQuery. Under the guidance of professional trainers you can get started with JavaScript, so that it does not remain a theoretical concept, but in practice you will learn what unique results you achieve with this scripting language.


You can learn programming!

Visit any vacancy site and you will see it immediately: there is an unprecedented demand for programmers. If you are looking for a paid job with excellent perspectives for the future, learning programming is a must. Even for jobs in which you don't directly program yourself, a programming language is an excellent addition to your CV. However, there are numerous programming languages, so where can you start best now? And which languages are interesting for the future? We made an overview of the 10 most important programming languages. Languages where you can also directly follow a training course: let those jobs come!


Java was for years the most-requested programming language for employers. Although this has recently been outpaced by SQL, it is still very popular. Java is the standard for many enterprise software, is used by more than 9 million developers and is used to control more than 7 billion (!) devices worldwide. Its popularity owes the programming language mainly to the simplicity and readability of the code, which makes it a good starting point for novice programmers. Also, one of the basics of Java is the compatibility that ensures that older applications continue to work.


You'll find SQL everywhere. Database technologies like MySQL, PostgreSQL and Microsoft SQL Keep banks, universities, hospitals, small and large companies running. It is not exaggerated to say that every computer and person with access to technology somehow comes into contact with SQL. For example, iOS and Android devices have access to SQLite, a SQL database, and numerous mobile applications that use SQL directly.


C originates from the early years 70, when it was developed as a generic, general programming language. As one of the oldest programming languages available, C gives us the building blocks for other popular languages such as C++, Java, JavaScript and Python. C itself is mainly used for operating systems and industrial applications.


C is an object-oriented programming language based on C. Since the language in the years 80 was developed it has been used to develop Adobe and Microsoft applications, MongoDB databases and large portions of Mac OS/X operating system. It is considered by many to be the best programming language to learn for applications where performance is of great importance, such as games or audio/videobewerking.

iOS/Objective C/Swift

Until 2014, objective C was the programming language used by the Apple operating system. It plays a role in Apple's OS X, iOS and its Apis. For a long time it was the language in which you had to write iPhone applications as a programmer, until Apple came up with its own programming language a few years ago: Swift. Swift seems to be very much like C++ and its predecessor objective C, but it is easier for most programmers to learn.


JavaScript – not to be confused with Java – is widely used to add interactivity to websites and is supported by all larger internet browsers. Not only can it be used for simple functionality like popups or simple games, it also forms the basis for Node. JS – A server technology that is widely used in real-time communication.


PHP was in fact never meant as a programming language. The Danish-Canadian programmer Rasmus Lerdorf developed PHP in 1994 as a series of tools that enabled him to manage his personal website (Personal homepage). Today we changed the meaning of the abbreviation to Hyper test Pre-Processor and used the language on servers to dynamically generate HTML websites. PHP is easy to learn, but in addition possesses much advanced functionality that is of great value for experienced programmers.


HTML forms the basis for Web pages. This does the programming language by actually setting a structure that can be extended or modified by other languages. For example, JavaScript can be used to add advanced interactivity, and CSS influences the presentation, formatting, and layout of Web pages. Although PHP can generate HTML from a server, knowledge of HTML and CSS for Web developers is an absolute must.


Python is a server-side programming language for websites and mobile applications. It is a relatively easy language to learn, thanks to the readability and brevity of the code. In Python, it is often possible to express a concept in less rules than in many other languages. Python is used in applications such as Insta gram and Pinterest in the form of the Web-framework Django. Google, Yahoo! and NASA all make use of Python.


Ruby is – like Python – a programming language that is very user-friendly for novice programmers. At the same time, the object-oriented language is very dynamic and thus popular for developing websites and mobile apps. It is the basis of the Ruby on Rails framework used by Groupon, Shopify, Scribd and GitHub.

Fill in the list!

Of course there are many more programming languages. We've just put a few of the most popular for you. Do you have additions? Are you missing a language that you really often use? Share your knowledge and experience with us!

Learning A (different) programming language yourself?

Do you want to learn a (different) programming language? Discover our workshops and courses quickly. Under the guidance of an experienced trainer, you will learn the basics of programming in an efficient way. Are you already a little further? Then it is possible to register for an advanced training. You go deeper into the matter. Such training is not only fun, but it also fits in well with the practice. So you are sure you can do something with your new knowledge and skills instantly!


5 reasons to communicate with your SQL database via PDO

There are several ways to communicate with a database from PHP. Since PHP 5.1 A nice extension has been released: PHP database Objects (PDO). Do you use the old fashioned mysql_connect() And mysql_query() Features? Here five reasons to switch:

  1. Binding parameter

    Creating a query with input from website visitors brings with it dangers. Visitor Input can contain dangerous SQL code. If the code component becomes a query there is a SQL injection, a common vulnerability.

    With PDO you can better arm against SQL injections thanks to ' parameter binding '. PDO offers the ability to use placeholders in your query. This will prevent unwanted SQL code from entering the query.

  2. Exploits of a mom

    Randall Munroe, xkcd.com, CC BY-NC 2.5

  3. Transactions

    Changes to your database are often not self-explanatory. Often, one request from the visitor asks for changes to multiple tables. When making an order in a webshop, not only the order must be saved, but also the inventory will be updated.

    If one of these queries does not go well, for example because the inventory is insufficient, the database will be in an inconsistent state. With transactions, you can do a "rollBack" in such a case, which will undo all changes to the database since the start of the transaction.

  4. ' Universal ' interface

    With PDO you are not tied to one database. No less than 12 database systems are supported, including MySql, PostgreSQL, Microsoft SQL Server and Oracle. Thanks to PDO, your program can communicate with it in the same way. When you connect, you indicate what type of database it is, then you can ask them using the same methods.

  5. Disappearance of old functions

    The obsolete mysql_*() Features are no longer supported from PHP version 5.5.0. In the latest versions (from PHP 7.0.0) They are not even included and therefore no longer use.

  6. Object oriented

    PDO is completely object oriented. So you have all the advantages of object oriented programming, including exceptions. Exceptions allow you to handle errors, such as connection problems, in an elegant way.

Note: Is the PDO extension not available on the system where your website Is running, and do you use a MySQL database? Then switch to Mysqli. Less universal and elegant than PDO, it also provides parameter binding, transactions and stored procedures.


Save visitor passwords securely with PHP? Use Hashing!

Again this week the weather was quite touching: The passwords of millions of internet users are on the street. While the creator of the website could have avoided this easily.

What is the danger?

Unlike computers, people are not really good at memorizing them. However, you have to remember passwords everywhere. As a result, many people use a single password for multiple websites. This entails a major security risk. If a password is leaked, all accounts can be accessed where this password has been reused.

How do you prevent visitor password theft?

The best solution to not steal passwords is simply not to keep them! Instead, we'll save the hash of the password. A hash function makes a password unrecognizable. Based on the hash, it is impossible to trace the input. A hash function always produces the same result with the same input. A strong hash function also ensures that two different texts do not result in the same hash (if this happens there is a collision). Even if the hackers manage to get a database with hashes, they don't have passwords in their hands yet.

How do you use the hash functions of PHP?

Since PHP 5.5 It has become very easy to hash passwords by using the function password_hash(). This function has one mandatory argument: the password. The second argument allows you to specify which hashing algorithm to use. If you do not specify this, the strong BCrypt algorithm is used by default. In addition to hashing, this function also adds a Salt which protects against Rainbow Tables. Generating the hash goes as follows:

  $wachtwoord = ' secret password ';
  $hash = Password_hash ($wachtwoord, PASSWORD_BCRYPT);
  Echo $hash;

The generated hash is a string of 60 characters and can look like this: $2y $10 $ Se3mLsHueAYTM3G4Wd9hTuyfzPCRYtafImcOSO2U0H4290jPU. SUA. From this hash it is impossible to retrieve the password. This hash can be stored securely in your database.

To check if someone has entered a correct password we use the function password_verify(). We give these two arguments, the password that was entered in the login and the hash that we had saved.

  $hash = '$2y$10$Se3mLsHueAYTM3G4Wd9hTuyfzPCRYtafImcOSO2U0H4290jPU.SGO';
  $wachtwoord = 'Onzin';

  if (password_verify( $wachtwoord, $hash)){
      echo 'Correct wachtwoord';
  } else {
    echo 'Incorrect wachtwoord';

In this case, the user password will generate a different hash than was stored in our database. This allows us to verify that the password you entered is correct, without having to save the original password. Even if a hacker gains access to our database there is no password to find.