
Answer-first summary for fast verification
Answer: `assert row_count == 10, 'Row count did not match'`
The correct answer is `assert row_count == 10, 'Row count did not match'`. This is because the `==` operator is used for equality comparison in Python, whereas `=` is an assignment operator. The `assert` statement does not require the `if` keyword. For more details, refer to the Python documentation on assertions.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Which of the following statements correctly tests if the number of rows in a table equals 10 in Python, using the provided code snippet: row_count = spark.sql('select count(*) from table').collect()[0][0]?
A
assert (row_count = 10, 'Row count did not match')
B
assert if (row_count = 10, 'Row count did not match')
C
assert row_count == 10, 'Row count did not match'
D
assert if row_count == 10, 'Row count did not match'
E
assert row_count = 10, 'Row count did not match'
No comments yet.