IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Intermediate Python for Developers

Visualizza il corso

Istruzioni dell'esercizio

  • 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.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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
____(____)
Modifica ed esegui il codice