python language simple
Computing an integer of 1 to 100 and
result = 0
for in range(1,100)
result += i;
print(s)
Calculate and output n!
def fact(n):
if n == 1:
return 1;
return n*fact(n-1)
print(fact(10))
No semicolon, no functional constraints, without braces, no begin / end
no type declaration, the variable is not defined, the pointer is not
the same functionality as python code amount is relatively small.
Open source ecosystem
has more than 140,000 third-party free libraries
python can encapsulate the underlying c / c ++ language code, and using python call.
Temperature Conversion
Colon + Indent: part of python syntax function, expression affiliations code
colon + indentation is part of the syntax, indentation is not correct program run error
colon + indentation is the only way to contain and hierarchical relationship between the expression of
only the needs of all indent to the same length, spaces can be N or Tab, four spaces recommendations
in python comments:
Single-line comments with a #
Use multi-line comments
'''
Lines of code
'''
Life character \
Note: in python T Rue, F alse, N One of these three keywords are beginning with a capital letter
Not including the last character
When a plurality of elements, and there is a correspondence between the elements, using ancestral type
Expresses the relationship of elements of an ordered set, once the tuple is created, it can not be modified
python input and output:
If TempStr is "82f"
TempStr [-1] is the last character of the string f
TempStr [0: -1] is a slice, showing that takes a string from 0 to before the last character of the character, 82
eval (TempStr [0: -1]) into a digital string 82