I have the following code:
for i in range(0,numClass):
if breaks[i] == 0:
classStart = 0
else:
classStart = dataList.index(breaks[i])
classStart += 1
classEnd = dataList.index(breaks[i+1])
classList = dataList[classStart:classEnd+1]
classMean = sum(classList)/len(classList)
print classMean
preSDCM = 0.0
for j in range(0,len(classList)):
sqDev2 = (classList[j] - classMean)**2
preSDCM += sqDev2
SDCM += preSDCM
return (SDAM - SDCM)/SDAM
I would like to convert this code to VB.NET.
But I am not sure where the if-elseif-statement ends. Does it end after "classStart += 1"?
I feel it a bit difficult to see where the for-next-loops end as well in Python.
The code is taken from http://danieljlewis.org/files/2010/06/Jenks.pdf
Thank you.
In Python, the body of the if statement is indicated by the indentation. The body starts with an indentation and the first unindented line marks the end. Python interprets non-zero values as True . None and 0 are interpreted as False .
An IF statement is executed based on the occurrence of a certain condition. IF statements must begin with the keyword IF and terminate with the keyword END.
The endif command is used to terminate a multiple line if command. The command can either be specified as a single word, 'endif' or as two separate words, 'end if'.
In the multiline syntax, the If statement must be the only statement on the first line. The ElseIf , Else , and End If statements can be preceded only by a line label. The If ... Then ... Else block must end with an End If statement.
Yes. Python uses indentation to mark blocks. Both the if
and the for
end there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With