ComeçarComece de graça

Report-generating function

You learned that functions can return values, but they can also print results.

Your development team needs regular reports on test execution times. Instead of manually calculating these metrics each time, you'll create a custom function called test_report that prints a formatted summary without returning any values.

A test_durations list with test execution times in seconds is provided for you.

Este exercício faz parte do curso

Python intermediário para desenvolvedores

Ver curso

Instruções do exercício

  • Complete the function definition by adding durations as the argument.
  • Calculate the total test time by using a built-in function on the durations.
  • Generate the report for recent tests by calling the function on the test_durations list.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

test_durations = [245.50, 189.99, 312.75, 156.20, 428.90, 201.35, 167.80]

 # Complete the function
def test_report(____):
    num_tests = len(durations)
    
    # Calculate total test time
    total_time = ____(____)
    
    print("=== Test Report ===")
    print("Total Tests: ", num_tests)
    print("Total Execution Time (s): ", total_time)

# Generate the report for recent test runs
____(____)
Editar e executar o código