python basis shorthand

input Output

输入
print('hello, world')
//会依次打印每个字符串,遇到逗号“,”会输出一个空格
print('The quick brown fox', 'jumps over', 'the lazy dog')
print('100 + 200 =', 100 + 200)

输出
name = input()
//input可以让你显示一个字符串来提示用户
name = input('please enter your name: ')
print('hello,', name)

Data types and variables

python can handle any size integer
Python floats will no size limit, but beyond a certain range is expressed directly INF (infinity).

String is a single quote 'or double quotes "any text enclosed
when' is part of the string, when using the" escape symbol used or
Python also allows' means' with r 'by default does not turn inside the string Yi
Python allows '' '...' '' is a multi-line format

"I'm OK"
'I\'m ok.'

print('''line1
... line2//注意这个...是程序提示符号
... line3''')
line1
line2
line3

In Python, can be directly used True, False Boolean value indicating (note the case)
Boolean values can be used and, or and not (non) operation

Null is a special value in Python, represented by None
None not be interpreted as 0, because 0 is meaningful, and None is a special null value.

Constant associated
in Python, usually expressed with constants in all uppercase variable names
but Python did not have any mechanism to ensure that it will not be changed, so, with all uppercase variable name indicates the usage of the constants just a habit

// base addition
takes only the integer part of

>>> 10 // 3
3
Published 127 original articles · won praise 16 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_41413511/article/details/104069992