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
Question 1 What do you mean by semantic networks? Explain inheritance in semantic networks Question 2 Explain Partitioned semantic networks with an example Question

The 7489 TTL Ram Device: The 7489 TTL Ram package has 64 memory cells, each cell is capable of holding a single bit of data.  The cells are organised into locations, and each l

#que1) Create telephone directory. • The heading should be 16-point Arial font in bold • The rest of the document should use 10-point font size • Other headings should use 10-point



Given the following grammar: -> [ , ] | -> | { } -> a | b | cwhich are the strings generated by the grammar? Show the parse tree(s). a). { [ a , b ] }b). [ { a } , b ]

Web Browser:   A Web browser is software application that enables you to find, retrieve, and display information available on the World Wide Web (WWW). Browser also allows you

Is IT a strategic weapon or a survival tool? Discuss.

The unconditional jumps in a written program in assembler language are specified by the jmp instruction; a jump is to moves the flow of the execution of a program by sending the co

One of the facilities that the use of macros provides is the formation of libraries, which are sets of macros which can be included in a program from a different file. The formatio