Quiz de programmation Python

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Quel est le résultat de l’instruction print 2 + 2==4 en Python?

  • True (correct)
  • 4
  • False
  • Erreur

Quelle est la sortie de ces instructions Python si l’utilisateur saisit 22. age=input() ; print(age+8)?

  • Erreur (correct)
  • 30
  • 22
  • 8

Quel est le résultat de l'expression True and False en Python?

  • True
  • 0
  • 1
  • False (correct)

En Python, le type d’une variable ne peut pas changer pendant l'exécution du programme.

<p>Vrai (B)</p> Signup and view all the answers

À quoi sert l'instruction continue en Python?

<p>À ignorer le reste du code dans la boucle et passer à l'itération suivante (B)</p> Signup and view all the answers

Quelle est la sortie du code suivant en Python . for i in range(3): print(i,end=''); break else: print(2)

Signup and view all the answers

Quelle est la sortie de l’instruction suivante en Python: print('Bonjour, monde.'[:3])

<p>Bon (D)</p> Signup and view all the answers

Comment peut-on obtenir un nombre flottant aléatoire entre 0 et 1 avec le module random en Python?

<p>random() (A)</p> Signup and view all the answers

Quelle est la fonction du module random qui génère un entier aléatoire entre 5 (inclus) et 10 (exclus) en Python?

<p>randint(5,10) (B)</p> Signup and view all the answers

Quelle est la sortie du code suivant en Python: if(True): print(1//2)

<p>0 (A), 0. (B), 0 (D)</p> Signup and view all the answers

Flashcards

Python print(2 + 2 == 4) output

The expression 2 + 2 == 4 evaluates to True in Python. The print() function displays this result.

Python input() error with addition

Trying to directly add the user input (which is a string) to a number will result in an error if it is not an integer.

Python True and False

The expression True and False evaluates to False in Python.

Python variable type immutability

In Python, a variable's type can change during execution.

Signup and view all the flashcards

Python continue statement

The continue statement skips the rest of the current loop iteration and goes to the next iteration.

Signup and view all the flashcards

Python for i in range(3): problem

The provided code includes a break within a for loop with an else block. The else block is skipped because of the break

Signup and view all the flashcards

Python string slicing 'Bonjour, monde.'[:3]

Extracts the first three characters of the string "Bonjour, monde."

Signup and view all the flashcards

Python random float

The function random.random() generates a random float between 0 (inclusive) and 1 (exclusive).

Signup and view all the flashcards

Python random integer

random.randint(5, 10) generates a random integer between 5 (inclusive) and 10 (exclusive).

Signup and view all the flashcards

Python if(True): print(1//2)

The 1 // 2 expression returns the integer part of the division (0).

Signup and view all the flashcards

More Like This

Python Syntax and Design Philosophy Quiz
6 questions
Python Basic Syntax Quiz
6 questions
Python Basics MCQ Quiz
5 questions
Introduction to Python Syntax
5 questions
Use Quizgecko on...
Browser
Browser