Help understanding range function and array indexing [closed]


I’m working on understanding the below solution of rotating an array of integers in Python:

  1. Does the range function start counting at 0?
  2. Do we assume array indexing starts goes 0,1,2… or 1,2,3…?
  3. Why do we need to transfer the rotated values from the new array a to the old array nums (last line)?

Solution:

class Solution:     def rotate(self, nums: List[int], k: int) -> None:         n = len(nums)         a = [0] * n         for i in range(n):             a[(i + k) % n] = nums[i]                      nums[:] = a 

It is supposed to work as follows: Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4]