Thursday , September 19 2024

Which of the following sentences are true? (Select two answers) nums = [1, 2, 3] vals = nums[-1:-2]

Questions BankCategory: Python Essentials 1Which of the following sentences are true? (Select two answers) nums = [1, 2, 3] vals = nums[-1:-2]
Which of the following sentences are true? (Select two answers)

nums = [1, 2, 3]
vals = nums[-1:-2]
  • nums and vals are of the same length
  • vals is longer than nums
  • nums is longer than vals
  • nums and vals are two different lists

Explanation: Remember that:

  • when using indices, a new list is created with the elements specified within the brackets,
  • the new list created only has one element: [3].

More Questions: Python Essentials 1 – Module 3 Test