Information

Author(s) Tanguy De Bels
Deadline No deadline
Submission limit No limitation

Sign in

Session 1: QCM

Pour mener à bien ces exercices, il est utile d'avoir lu le cahpitre 1 du syllabus : https://syllabus-interactif.info.ucl.ac.be/syllabus/info1-theory/PART_I


Question 1: Variable assignment

Pick the piece of code which will print 42.

Question 2: Intervals

In mathematics, we define intervals, closed, open and semi-open. The semi-open interval \([3,7[\) includes all real numbers that are greater than or equal to 3 and strictly less than 7. Which of the following code fragments display true on the standard output if and only if x belongs to the interval \([a, b[\) ? We assume for this question that the value stored in the variable a is strictly less than the one stored in the b variable.

Question 3: Operators usages

Which of the following code fragments prints 14?

Question 4: While loops

Which of the following code fragments calculates the sum of the first n positive integers?

Question 5: Python syntax

Which of the following program fragments respects the syntax and semantics of the language?

Question 6: Comments in Python

Check the snippets which contain a valid comment.

Question 7: Exchange variables values

It is often useful to be able to swap values between variables. Consider the following variables:

a = 42
b = 41

Which of following code fragments swap the values correctly?

Question 8: Calculate min

Consider a program that manipulates two variables: a and b . Among the code fragments below, which one correctly stores in the variable min the minimum of the contents of the variables a and b ?

Question 9: Absolute value

Which of these code fragments places in the variable abs the absolute value of x ?