# Use these as example inputs for A and B
A = [1,3,2,4,5,3,4,2,1]
B = {1:2, 2:1, 3:4, 4:2, 5:3}

# Make a function to do the calculation
# Takes the two values needed for the calculation
def CR_calc(value, CR_value):
	# explicitly convert the integers to floats, to make sure we get true division
	out = (float(value)/float(CR_value))**2
	# handle special case where the value is < 1
	if out < 1:
		out =0
	# return the value for this pair of values
	return out

# Create an array for the result, initialising it with 0s
result=[0]*len(A)

# Iterate along the A array
for i in range(len(A)):
	# Nested indexing for B, so we get the matching value for whatever A[i] is
	result[i] = CR_calc(A[i],B[A[i]])

# Prints the result array nicely
print(result)

# output:
# [0, 0, 4.0, 4.0, 2.777777777777778, 0, 4.0, 4.0, 0]
