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
Search strategy-artificial intelligence: Soundness: You  can hear  in  some  application domains  -  i.e.  automated  theorem proving - that a search is "sound and complet

solution of two degree of freedom system with matlab program???

explain ipx for lan and spx

Depth First Search-Artificial intelligence: Depth first search is  similar to breadth first, except that things are added to the top of the plan rather than the bottom. In our

Regardless of of the fact that a thread must execute in process, the process and its associated threads are different notion. Processes are used to group resources together and thr


Write an alogorithm to calculate the right angled triangle

Conditional statement: An If statement is composed of three parts. The first part should be keyword w.r.t language to convey to the computer that it is if statement. And a Bo

what is member dereferencing oprator ?

COMMUNICATION CHANNELS: A wire pair connecting two telephones is the simplest circuit, allowing communication in both directions. Other channels include coaxial cables, optica