nerdexam
Juniper

JN0-224 · Question #131

Given the following Python script: a = [1,2,3,4,5,6,7,8,9] print(a[0]) What is the output of this print command?

The correct answer is A. 1. In Python, lists are zero-indexed, meaning the first element of the list is at index 0. The given pythona = [1, 2, 3, 4, 5, 6, 7, 8, 9] a[0] refers to the first element in the list a, which is 1. So, the output of the print(a[0]) command is 1. Option A is correct because Python…

Python

Question

Given the following Python script:

a = [1,2,3,4,5,6,7,8,9] print(a[0]) What is the output of this print command?

Options

  • A1
  • B2
  • C7
  • D9

How the community answered

(40 responses)
  • A
    93% (37)
  • B
    5% (2)
  • D
    3% (1)

Explanation

In Python, lists are zero-indexed, meaning the first element of the list is at index 0. The given pythona = [1, 2, 3, 4, 5, 6, 7, 8, 9] a[0] refers to the first element in the list a, which is 1. So, the output of the print(a[0]) command is 1. Option A is correct because Python indexing starts at 0, making the first element of the list at

Topics

#Python lists#zero-based indexing#list access#data structures

Community Discussion

No community discussion yet for this question.

Full JN0-224 Practice