Lists versus arrays under multiplication

An engineer intends to double three loads, measured in kN, and checks the results by comparing their totals:


Python
import numpy as np
F_list = [2.0, 4.0, 6.0]      # loads, kN
F_arr = np.array(F_list)
a = F_list * 2
b = F_arr * 2

if sum(a) == np.sum(b):
    result = (len(a), float(np.mean(a)), float(np.mean(b)))
else:
    result = None


What value does result hold, and what does it reveal about the engineer's check? The tuple contains the number of elements in a, the mean of a in kN, and the mean of b in kN, respectively.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Python Programming Questions: