Designed to be a write-less-do-more language, Python has certain aspects that differ from Java:
- It is an interpreted language, which means no compilation is required.
- It is not a strongly typed language
- Its statement grouping is done by indentation instead of open and close braces
- It does not require declaration of variable or argument
- It supports complex number, for example (using Python interactive interpreter)
- Strings can be subscripted. For example, the first character of a string has index 0.
- It supports multiple assignment, for example, 'a,b=b,a+b', where the expression on the right-hand side 'b,a+b' are evaluated first before any of the assignments take place
- Not surprisingly, it supports lamda forms
- It supports map and reduce functions as part of its functional programming offerings
- It supports Tuples, which are immutable and usually contain an heterogeneous sequence of elements
- It allows multiple inheritance, for example
>>> 1j + 2J (-2+0j) >>> (1+2j) * complex(2,3) (-4+7j)
>>> word="HelloWorld" >>> word[4] 'o' >>> word[1:3] # using the slice notation, returning characters from index 1 to 2 'el'
>>> def incresedBy(n): ... return lambda x: x + n ... >>> f = incresedBy(42) >>> f(1) 43
>>> t=123,321,'hello' >>> t (123, 321, 'hello')
class DerivedClassName(Base1, Base2, Base3): <statement-1> . . . <statement-N>
No comments:
Post a Comment