What makes up a block of code?
Any time you hear something referred to as a block or block of code it typically means the same thing. At least in programming.
There’s no better way to explain it than to show you visually! Don’t worry about understanding the code below, but understand that the chunks of code written at the same indentation level in Python make up a block of code. Notice the small gray arrow on line 4? That indicates a block of code belonging to whatever is on the line with the arrow - a function in this case.
Hello, how can I call that block code inside my_function and how can I name my_function?
the general syntax for a function:
def is short for define. So here you define the function, then you name the function anything you like, then to call the function do:
A block of code is composed of several statements that are intended to execute when certain condition is met. In Python, a block of code is implemented using indentation.
print "this is the first line of the block"
print "this is the second line of the block"
print "this is the third of the block"
print "this is the first line of another block"
print "this is the second line of another block"
print "this is the third of another block"
A post was split to a new topic: Learning python