← All HACKERRANK Flashcard Decks

Scalar Types and Operators Flashcards

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

Read the first 7 Scalar Types and Operators flashcards as text
  1. What is the result of `7 // 2` in Python?

    Answer: 3

    The `//` operator performs floor division, truncating the decimal portion and returning an integer.

  2. Which of the following correctly converts the string `'42'` to an integer?

    Answer: int('42')

    The built-in `int()` function converts a string representation of a whole number to an integer.

  3. What does `type(3.0)` return?

    Answer:

    Any number written with a decimal point is treated as a `float` in Python, and `type()` returns the class object.

  4. What is the value of `True + True + False`?

    Answer: 2

    In Python, `bool` is a subclass of `int`; `True` equals `1` and `False` equals `0`, so the sum is `2`.

  5. What does the expression `not (3 > 2)` evaluate to?

    Answer: False

    `3 > 2` is `True`, and `not True` returns `False`.

  6. Which operator is used for exponentiation in Python?

    Answer: **

    Python uses `**` for exponentiation; `^` is the bitwise XOR operator.

  7. What is the result of `10 % 3`?

    Answer: 1

    The modulo operator `%` returns the remainder after division; `10 ÷ 3` has remainder `1`.