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
---
shuffle: true
---
# What is an algorithm?
What is an algorithm?
- [x] A solution to a specific problem that takes input values and produces a result value.
- [ ] A sequence of algorithmic statements applied to input data.
- [ ] A way to compare different solutions to a problem.
- [ ] A set of instructions to create a cake.
# What is an algorithm?
How can algorithms be compared?
- [x] By their complexity.
- [x] By the time they take to produce the output value.
- [x] By the memory space they require during processing.
- [x] By their use of randomness.
# What is an algorithm?
What is pseudo-code?
- [x] A syntax restricted to algorithmic statements.
- [x] A less rigorous form of formal programming languages.
- [x] A way to quickly write algorithms without focusing on programming language details.
- [x] A mathematical formulation of an algorithm.
# What is an algorithm?
What is the advantage of using standard functions in programming languages?
- [x] It saves time.
- [x] It provides optimized and efficient solutions.
- [ ] It increases the size of the codebase.
- [ ] It reduces the memory space required.
---
shuffle: true
---
# What is a variable?
What is a variable?
- [x] A constant with a name
- [ ] A memory address
- [ ] An assignment operator
- [ ] A dynamically typed language
# What is a variable?
Which of the following is a basic type?
- [ ] Array
- [x] Integer
- [x] String
- [x] Float
- [x] Character
- [x] Boolean
- [ ] Function
- [ ] Program
# What is a variable?
In Python, the type of a variable is :
- [ ] Determined at compile time
- [x] Determined at runtime
- [ ] Required to be explicitly declared
- [x] Optional
# What is a variable?
How do you assign a value to a variable in Python?
- [x] `variable = value`
- [ ] `variable == value`
- [ ] `value <- variable`
- [ ] `variable := value`
- [ ] `value = variable`
# What is a variable?
In Python (and Java), elements in an array are numbered starting from:
- [x] 0
- [ ] 1
# What is a variable?
**Negation of a conjunction**:
I live in Brest if I like the seaside (proposition
$S$) and meeting cool people (proposition
$C$), formalized as
$S \wedge C$.
The negation of this conjunction
$\neg(S \wedge C)$ is equivalent to:
- [x]
$\neg S \vee \neg C$
- [ ]
$\neg(S \vee C)$
- [ ]
$\neg S \wedge \neg C$
---
shuffle: true
---
# Algorithmic statements
What is a statement?
- [x] A basic instruction that can be executed by a computer.
- [ ] A mathematical formula.
- [ ] A logical proposition.
- [ ] A function.
# Algorithmic statements
An invariant is a Boolean condition that has to be true:
- [x] Before entering the iteration.
- [x] After each round of the iteration.
- [x] At the end of the iteration.
- [ ] Once the iteration terminated.
- [ ] Only before the first round of the iteration.
# Algorithmic statements
A loop :
- [x] Is a way to repeat a block of code.
- [ ] Is a way to execute a block of code only once.
- [ ] Is a way to execute a block of code in parallel.
- [ ] Can only be used with arrays.
- [ ] Is unbounded.
- [x] Can lead to infinite loops.
# Algorithmic statements
What is the order of the values of *T* if the following iteration is applied
```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]
```
1. 0
2. -5
3. 1
4. 3
5. 5
6. 4
7. 8
8. 9