High School

What is the output of the following code:

nums = [100, 200, 300, 400]
print(sum(nums) / len(nums) * min(nums))

250
2500
25000
250000

Answer :

To determine the output of the given code, we need to evaluate each component of the expression step by step:

  1. Identify Components of the List:

    • The list nums is [100, 200, 300, 400].
  2. Calculate the Sum:

    • First, we calculate the sum of the numbers in the list:
      [tex]\text{sum(nums)} = 100 + 200 + 300 + 400 = 1000[/tex]
  3. Calculate the Length:

    • The length of nums is the number of elements in the list:
      [tex]\text{len(nums)} = 4[/tex]
  4. Calculate the Average:

    • Next, we find the average (mean) by dividing the sum by the length:
      [tex]\text{Average} = \frac{\text{sum(nums)}}{\text{len(nums)}} = \frac{1000}{4} = 250[/tex]
  5. Find the Minimum Value:

    • Find the smallest number in the list:
      [tex]\text{min(nums)} = 100[/tex]
  6. Final Calculation:

    • The final expression multiplies the average by the minimum value:
      [tex]250 \times 100 = 25000[/tex]

Therefore, the output of the code is 25000.