โ† All Mettl Flashcard Decks

Fundamental Coding Skills Flashcards

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

Read the first 7 Fundamental Coding Skills flashcards as text
  1. What is the time complexity of accessing an element in an array by index?

    Answer: O(1)

    Array index access is O(1) because the memory address is computed directly from the base address and index.

  2. Which of the following correctly declares a constant in JavaScript?

    Answer: const PI = 3.14;

    The `const` keyword declares a block-scoped constant that cannot be reassigned after initialization.

  3. What does the modulo operator (%) return?

    Answer: The remainder after division

    The modulo operator returns the remainder when the left operand is divided by the right operand.

  4. Which data structure follows the LIFO (Last In, First Out) principle?

    Answer: Stack

    A stack is a LIFO structure where the last element pushed is the first one popped.

  5. What will `print(type([]))` output in Python?

    Answer:

    Square brackets `[]` create a list in Python, so `type([])` returns ``.

  6. In most programming languages, what is the index of the first element of an array?

    Answer: 0

    Most languages (C, Java, Python, JavaScript) use zero-based indexing, so the first element is at index 0.

  7. What is the output of the following Python code: `x = 5; x += 3; print(x)`?

    Answer: 8

    `x += 3` is shorthand for `x = x + 3`, so x becomes 5 + 3 = 8.