← All Mettl Flashcard Decks

Coding Skills Flashcards

6 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 6 Coding Skills flashcards as text
  1. What will the following Python code output? x = [1, 2, 3, 4, 5] print(x[1:4])

    Answer: [2, 3, 4]

    Python slicing x[1:4] returns elements at indices 1, 2, 3 (not including index 4): x[1]=2, x[2]=3, x[3]=4. Result: [2, 3, 4].

  2. What is the time complexity of binary search?

    Answer: O(log n)

    Binary search halves the search space with each comparison, giving O(log n) time complexity.

  3. Which SQL statement is used to retrieve unique values from a column?

    Answer: SELECT DISTINCT

    SELECT DISTINCT eliminates duplicate rows from the result set.

  4. In object-oriented programming, what is 'encapsulation'?

    Answer: Bundling data and methods into a single unit and restricting access

    Encapsulation bundles data (attributes) and the methods that operate on that data into a single unit (class) and controls access through access modifiers.

  5. What does the following pseudocode return for input n=5? function factorial(n): if n == 0: return 1 return n * factorial(n-1)

    Answer: 120

    factorial(5) = 5 × factorial(4) = 5 × 4 × 3 × 2 × 1 = 120.

  6. What is the output of: print(type(3.14)) in Python?

    Answer:

    3.14 is a floating-point number. In Python, type() returns for floating-point values.