Points to Remember
The basic rules to write a Jython program are:Code execution
Statements are executed in sequence up to a control structure: if, for, while, raise , or a function call.Block
A block is defined by lines with the same indentation level (spaces or tabulations).Statements
A statement stops at the end of a line, and can be continued on several lines if they end with a \, or if they are enclosed in (), [], {} or '''. Several instructions can be on the same line if they are separated with a ;.Comments
A comment starts with a hash character # and ends at the end of the physical line.String Documentation
If a function, a module or a class starts with a string constant, this string is stored in the __doc__attribute of the object.Examples
Simple program that displays "Hello World"# Assign a value to a string
s = 'Hello World'
# Display the value
print s
Program that displays "Hello World" 4 times
s = 'Hello World %d'
for i in range(4):
j = i * 2
print s % j
No comments:
Post a Comment