Lines and Indentation in python , Basic Computer Science

One of the first caveats programmers come across when learning Python is the reality that there are no braces to point to blocks of code for class and function definitions or flow control. Blocks of code are indicated by line indentation, which is strictly enforced.
A number of spaces in the indentation is variable, but all statements in the block must be concave the same amount. Both blocks in this illustration are fine:
if True:
print "True"
else:
print "False"
On the other hand, the second block in this instance will generate an error:
if True:
print "response"
print "True"
else:
print "response"
print "False"
Thus, in Python all the continuous lines indented with same number of spaces would form a block.

Posted Date: 5/5/2012 3:12:30 AM | Location : United States







Related Discussions:- Lines and Indentation in python , Assignment Help, Ask Question on Lines and Indentation in python , Get Answer, Expert's Help, Lines and Indentation in python Discussions

Write discussion on Lines and Indentation in python
Your posts are moderated
Related Questions
Microcontroller: A highly integrated microprocessor designed specifically for use in embedded systems. Microcontrollers typically includes an integrated CPU, memory (a small amount

• CPU Structure This section, with a simplified model of a central processing unit as an instance, takes you through the role of each of the major basic parts of the CPU. It also l

access,excel and ms word/

Laser Printers: These printers can print a whole page at one command, offer highest quality and can combine text, graphics, etc. They are generally restricted to A4 paper and

Below you will find a question the areas of automata. Solve the problem showing all steps. Thoroughly explain how and why you performed each step with complete sentences. A finite

Library function :   These are the functions supplied with the programming language. The code or definition of library functions does not have to be written in a user program w

what are the phases of oo progarmming or java?



SPECIAL-PURPOSE AND GENERAL-PURPOSE COMPUTERS In general, there are two types of digital computers. The first is the special-purpose digital computer, which performs a f