Self-assessment quiz

Presentation & objectives

The following quizzes are here to help you check that you understood the articles you had to study. They are provided for self-assessment and will not be graded or stored.

Don’t hesitate to reach out on the Discord server for any precision/explanation!

Quizzes

--- secondary_color: lightgray --- # What is a program? Rank order the different phases the Python interpreter goes to when interpreting your code. 1. Detect lexical errors as encoding mismatch. 2. Check the syntactic structure of the code to detect ill-formed statements. 3. Compile the Python source code into byte code to faster its execution. 4. Load and execude the code in the Python virtual machine. ## How to improve the following code to make it easier to understand and extend? ```python from typing import List T : List[int] = [5, 4, 8, 9, 0, -5, 1, 3] i : int = 1 j : int = 0 while i < len(T) - 1: if T[i] < T[len(T) - 1]: T[j] += T[i] T[i] = T[j] - T[i] T[j] = T[j] - T[i] j += 1 i += 1 T[j] += T[len(T) - 1] T[len(T) - 1] = T[j] - T[len(T) - 1] T[j] = T[j] - T[len(T) - 1] ``` - [ ] Use more parentheses and brackets. - [x] Add comments. - [x] Use more explicit names for the variables. - [x] Avoid having at two places (within and after the iteration) three lines of code doing the same thing. - [ ] Regroup the some statements on a same line. - [ ] Add semi-colon at the end of each line.