Skip to content
C

Test a Square Function

Easypython

Write and test a function square(n) that returns n ** 2, checking both a positive and a negative input — following pytest's plain-assert style.

Why not run real pytest? an automated judge grades exact program output, and pytest's own test-runner output includes non-deterministic timing (e.g. "3 passed in 0.02s") — so instead, write the assertions directly in the script and print a fixed summary once they all hold, which is exactly what a passing pytest run means in spirit.

Approach: define square(n), then use plain assert statements (pytest style) to check it against both given inputs, printing a summary once both checks pass.

Input: Two lines: a positive test input a, and a negative test input b.

Output: One line: 2/2 tests passed.

Input (stdin)

Output

Run your code to see output here...