Bird
0
0

Given the following code snippet for a 3x3 board, what will be the output if the board is [['X','X','X'],['O','O',''],['','','']]?

medium📝 Analysis Q4 of 15
LLD - Design — Tic-Tac-Toe Game
Given the following code snippet for a 3x3 board, what will be the output if the board is [['X','X','X'],['O','O',''],['','','']]?
def check_row_win(board):
    for row in board:
        if all(cell == 'X' for cell in row):
            return True
    return False

print(check_row_win(board))
AError
BFalse
CNone
DTrue
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the board and function logic

    The first row is ['X','X','X'], so all cells equal 'X' is True, function returns True immediately.
  2. Step 2: Confirm function output

    Since the first row satisfies the condition, the function prints True.
  3. Final Answer:

    True -> Option D
  4. Quick Check:

    Row with all 'X' returns True [OK]
Quick Trick: First matching row returns True [OK]
Common Mistakes:
MISTAKES
  • Ignoring early return
  • Assuming function checks columns
  • Expecting False due to other rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes