human
Sum of all subarrays of size K | Function to find the sum of all subarrays of size K.
Loop to consider every subarray of size K.
Initialize sum = 0.
Calculate sum of all elements of current subarray.
Prsum of each subarray.
Driver Code.
Function Call"
How can the above be solved in Python?
 ... Give me a code to sum of all subarrays of size K and the other steps required?
assistant
#Here is code to sum of all subarrays of size K and the other steps required.
 def calcSum ( arr , n , k ) :
	for i in range ( n - k + 1 ) :
		sum = 0
		for j in range ( i , k + i ) :
			sum += arr [ j ]
		print ( sum , end = " ▁ " )
arr = [ 1 , 2 , 3 , 4 , 5 , 6 ]
n = len ( arr )
k = 3
calcSum ( arr , n , k )