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 are the five subscriber-related signaling functions performed by the operator? Question 2 Compare Microprogrammed control and Hard-wired control Que

Question (a) What is a view? (b) Can we use a view to insert or update a record into a table? Do we have any limitation to perform the above command? (c) The syntax to cr

Information Units In order for the PC to process information, it is essential that this information be in unique cells called registers. The registers are sets of 8 or 16 flip-flop

Python is an interpreted, high-level, interactive and object oriented-scripting language. Python was designed to be extremely readable which uses English keywords commonly where as

Fundamentals of IT 1. How do you insert a symbol in a Word document? 2. Explain absolute cell addressing? 3. Discuss Custom List? 4. Explain applications of Multimedia

Problem 1 Research designs have a critical and directive role to play in the research process. Explain the meaning of research design. Describe the various types of research de

QUESTION (a) Describe what you understand by (i) "openness" and (ii) "Scalability" of a distributed system (b)What is the role of middleware in a distributed system? (c)

Compare and contrast two qualitative analysis approaches. You must select two that are a true contast eg  CAQADS (say leximancer ) v discourse analysis or thematic analysis by hand

Analogue and digital signals: Analogue (continuous) information is made available in virtually all aircraft equipment.  Figure 1 shows the analogue signal created by a variable

• A multilevel queue scheduling algorithm divides the ready queue in several separate queues, for example • In a multilevel queue scheduling processes are lastingly assigned to one