>>> message ='And now for something completely differentt'>>> n =17>>> pi =3.141592653589793
状态图(state diagram):展示了每个变量所处的状态;
2、变量名
变量名:存放值,一般选用有意义的名字—它们可以记录该变量的用途;
变量名命名规定:
变量名可以任意长;
变量名可以包括字母、数字和下划线;
变量名不能以数字开头,但可以是下划线;
变量名大小写字母都被接受,惯例只用小写字母;
变量名不能用关键词;
>>> pi =3.14>>> _pi =3.14>>> my name ='Shaofeng'
File "<stdin>", line 1
my name ='Shaofeng'^
SyntaxError: invalid syntax
>>> myname ='Shaofeng'>>> 51job ='51job'
File "<stdin>", line 1
51job ='51job'^
SyntaxError: invalid syntax
>>> MyName ='Shaofeng'
关键字(keywords):解释器使用关键字识别程序的结构;
>>>class=50
File "<stdin>", line 1class=50^
SyntaxError: invalid syntax
PS C:\Users\Administrator> python
Python 3.8.6(tags/v3.8.6:db45529, Sep 232020,15:52:53)[MSC v.192764 bit (AMD64)] on win32
Type "help","copyright","credits"or"license"for more information.>>>55>>> x =5>>> x +16
>>>'Hello'+'World''HelloWorld'>>>'Hello'+3
Traceback (most recent call last):
File "<stdin>", line 1,in<module>
TypeError: can only concatenate str(not"int") to str>>>'Hello'*3'HelloHelloHello'>>>'Hello'*-3''>>>'Hello'*0''>>>'Hello'*3.5
Traceback (most recent call last):
File "<stdin>", line 1,in<module>
TypeError: can't multiply sequence by non-int of type 'float'