Python code line by line:
-
This imports Python's built-in array module and gives it the alias arr.
-
The array module provides a space-efficient array data structure (like a list but with a fixed type).
-
This creates an array named nums.
'b' means the array will store signed integers (1 byte each, ranging from -128 to 127).
-
The array initially contains: [5, -2, 7, 0, 3].
-
This removes the first occurrence of -2 from the array.
-
Now the array becomes: [5, 7, 0, 3].
-
This prints the index of the first occurrence of the value 3 in the array.
-
Since 3 is now at index 3 (0-based index), it prints: 3.
Final Output:


0 Comments:
Post a Comment