Python
Version
Running on Python v3.11.8
Supported languages
Python
Testing framework
Special reminders and implementation details
py
from pytest import mark as m
from challenge.app import helloWorld
@m.describe("app.py")
class TestHelloWorld:
@m.it("Should return 'Hello World!'")
def test_return_hello_world(self):
assert helloWorld() == 'Hello World!'
Included libraries
How to debug
Debugging Python code is essential for every developer. One of the most straightforward yet effective ways to debug is by using print()
statements.
Steps to Debug Using Print Statements
Identify the Problem Area: Locate the section of your code where you suspect the problem might be.
Insert
print()
Statements: Addprint()
statements before and after the suspected problematic code to print out variable values and flow control.Check the Results Output of your tests
Analyze the Output: Look at the values printed in the results console to understand what's going wrong in your code. Adjust your code based on the findings and repeat as necessary.
Here’s an example of how to use print()
for debugging:
python
def calculate_sum(a, b):
print("calculate_sum called with arguments:", a, b) # Log function call
sum_val = a + b
print("Sum after addition:", sum_val) # Log sum calculation
return sum_val
result = calculate_sum(5, 10)
print("Result of calculate_sum:", result) # Log the result