Practical 7 - Python Introduction
7️⃣

Practical 7 - Python Introduction


  • Imperative Programming ↔ Declarative Programming
    • Imperative Programming are commands that direct the computer directly. Machine hardware are the implementations of these imperative instructions and are itself imperative (e.g. “add” or “subtract”). Both structural and object-oriented programming is imperative.
      • Structured Programming orders code in blocks (e.g. if, for, while statements), functions and modules. Functions or procedures allow for the re-use of code, which is why it is often called procedural programming. Modules are packages of functionally related code. A modular programming paradigm splits a program into independent and reusable modules.
    • Declarative Programming defines “what” but not “how”. For example, it needs a symbolic derivation of mathematical functions. It requires the programmer to define the logic that should be evaluated but not the actual form in which it is calculated.
      • Functional Programming shapes a program as a series of expressions (i.e. mathematical and programmatic expressions). It allows the use of pure functions which will always return the same output given the same input. It does not change anything else in the program state!
      • Logical Programming is another kind of declarative programming which shapes a program as a set of logical expressions or clauses. The clauses are evaluated by a proof builder that calculates solutions.
  • In general, imperative programming involves a series of commands the directly change the state (i.e. the variables) of the program.
  • Most modern computer programming languages are imperative (e.g. Python, Java, C++, C, …)
  • A compiler translates human readable code into machine readable code

1 - Python

  • Python is compiled into byte code, which is then interpreted by a virtual machine. It is possible to compile python, but this requires inferring types of variables at compile time.