The rule is very simple: every time there is a colon : in python code, it is the beginning of a non empty indented block
def foo(): # <- see the colon here ?
bar() # <- this line is indented (preferably with 4 spaces)
baz() # <- this line too
qux() # <- not indented: this line is outside function foo.
if x == 0: # <- a colon
if y == 3.14: # <- a colon
else: # <- else has the same indentation as the corresponding if
else: # <- a colon
pass # <- a do-nothing statement to fill the else block
etc() # <- this line is not in a block
if it is indented, it means it's "With" anotther block of code.
you need to indent evry time there is a colon.If you've seen one already, double indent.
print "bar" #part of the function "foo"
print 5+4 #also part of "foo"
print "eggs" #part of if and foo
if 1+1 == 20:
print"FAIL" #part of foo,if,if
elif 1+1 == "2":
print"FAIL" #part of foo if and elif
print" done with if" #part of if and foo
return 5 #part of foo and only foo
foo() #not part of foo because it isn't indented
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...