2  Why Python?

Python is a versatile programming language that is widely used in various fields, from web development to scientific computing. Here are some reasons why Python is a popular choice for beginners and professionals alike:

Figure 2.1: TIOBE index (monthly) estimates relative popularity of programming languages using data on engineers, courses, vendors, and major search engines. It reflects popularity, not quality or total code written.

2.1 Disadvantages

Python is not without its drawbacks. Since it is an interpreted language (i.e., executed line by line by an interpreter, without prior compilation), it may not be as fast as compiled languages like C or C++. However, Python can be optimized using libraries like NumPy and Cython, which implement performance-critical code in C. Also, there have been improvements in Python’s performance over the years. Figure 2.2 illustrates the performance difference between Python and other programming languages using a simple example of nested loops.

Figure 2.2: 1 billion nested loops in different programming languages. A “loop” is a programming construct that allows you to repeat a block of code multiple times. In this example, repeating a simple block one billion times is used to compare the performance of different programming languages. The speed with which the ball completes the journey indicates the performance of each language. Notice how Python is significantly slower than other languages like C, C++, and Java. (Do not worry about this for now; Python allows for many optimizations that can significantly improve its performance.)

2.2 Python in the IEM Program

In the IEM program, you will work with several MILP solvers, such as Gurobi and CPLEX, which have Python APIs. You will also use Python libraries like NumPy, Pandas, and Matplotlib for data analysis and visualization.