Questenaتمرینی که نشان می‌دهد بعد چه چیزی را مرور کنید
سؤال 32

After `items = [3, 1, 2]` and `result = sorted(items)`, which state is correct?

  1. Both `items` and `result` are `[1, 2, 3]`.
  2. `items` is `[1, 2, 3]`; `result` is `None`.
  3. `items` stays `[3, 1, 2]`; `result` is `[1, 2, 3]`.پاسخ درست
  4. `result` is an iterator over the unchanged list.

توضیح

The built-in function constructs a new sorted list for `result` and leaves its input list in the original order. Saying the input is rearranged applies the behavior of `items.sort()` to the different `sorted` operation.

ادامهٔ این آزمون

شروع تمرین
سؤال 32: After `items = [3, 1, 2]` and `result = sorted(items)`,… · Python Fundamentals · Questena