โ† All Python Flashcard Decks

Data Types and Variables Flashcards

7 cards from real Python practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Data Types and Variables flashcards as text
  1. What is the result of `0.1 + 0.2 == 0.3` in Python?

    Answer: False

    Floating-point representation errors mean 0.1 + 0.2 is not exactly 0.3 in IEEE 754.

  2. Which module provides the `Decimal` type for exact decimal arithmetic?

    Answer: decimal

    The `decimal` module provides the `Decimal` class for arbitrary-precision decimal arithmetic.

  3. What is the output of `print(10 // 3)`?

    Answer: 3

    Floor division `//` divides and rounds down to the nearest integer, giving 3.

  4. Which built-in function converts a string of binary digits to an integer?

    Answer: int(x, 2)

    `int(x, 2)` interprets the string `x` as a base-2 (binary) number.

  5. What type does `x` have after `x = []`?

    Answer: list

    Square brackets `[]` create an empty list object.

  6. What is the result of `bool('')`?

    Answer: False

    An empty string is falsy in Python, so `bool('')` returns `False`.

  7. Which of the following creates a bytes literal in Python?

    Answer: b'hello'

    Prefixing a string literal with `b` (e.g., `b'hello'`) creates a bytes object.