Thông tin

Tác giả Tanguy De Bels
Hạn chót Không có hạn chót
Giới hạn nộp bài Không có giới hạn

Đăng nhập

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


Câu hỏi 1: Variable assignment

Pick the piece of code which will print 42.

Câu hỏi 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.

Câu hỏi 3: Operators usages

Which of the following code fragments prints 14?

Câu hỏi 4: While loops

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

Câu hỏi 5: Python syntax

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

Câu hỏi 6: Comments in Python

Check the snippets which contain a valid comment.

Câu hỏi 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?

Câu hỏi 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 ?

Câu hỏi 9: Absolute value

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