A. No error, test passes because strings differ in case
B. Syntax error due to missing parentheses
C. Assertion should use == instead of !=
D. Variables s1 and s2 are not defined
Solution
Step 1: Compare string values with case sensitivity
Strings "hello" and "Hello" differ in case, so they are not equal.
Step 2: Check assertion correctness
The assertion assert s1 != s2 correctly checks that the strings are not equal, so the test passes without error.
Final Answer:
No error, test passes because strings differ in case -> Option A
Quick Check:
"hello" != "Hello" is True [OK]
Hint: String comparison is case-sensitive by default [OK]
Common Mistakes:
Assuming strings are equal ignoring case
Expecting syntax error without parentheses in assert
Confusing == and != in assertions
5. You want to write a pytest test to check that a function get_status() returns a value that is not equal to None. Which assertion is the best choice?
hard
A. assert get_status() == None
B. assert get_status() is not None
C. assert get_status() != None
D. assert get_status() is None
Solution
Step 1: Understand None comparison best practice
In Python, to check if a value is not None, the recommended way is to use is not None rather than != None.
Step 2: Evaluate options for correctness
assert get_status() == None checks equality to None (wrong for this case). assert get_status() != None uses != None (works but not best practice). assert get_status() is not None uses is not None which is best practice. assert get_status() is None checks if value is None (opposite of requirement).
Final Answer:
assert get_status() is not None -> Option B
Quick Check:
Use 'is not None' for None checks [OK]
Hint: Use 'is not None' to check for non-None values [OK]
Common Mistakes:
Using == None instead of is None
Using != None instead of is not None
Confusing equality with identity for None
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.