Show user input
user = Raw_input (' Enter first Name: ')//raw_input is a built-in function
====> Enter first Name: root
print ' name is: ', User===>name is:root
int () string to digit
num = Raw_input (')
1024
print '%d '% (int (num) *2)
2048
#为注释
Symbol: +,-,*,/. Basic symbols
Floating-point division,% remainder, * * exponentiation
comparison operator >,>=,<,<=,==,!=
Logical operations: and OR not
Number type: Int,long,bool,float,complex
String: pystr= ' Python '
Iscool = ' is cool! '
Pystr[0]===> ' P '//Take first character
Pystr[2:5]===> ' tho '//Fetch 2--5 Index
Iscool[:2]==> ' is '//fetch from head to index 2
Iscool[3:]==> ' cool! ' Index 3 to the end
Iscool[-1]===> '! ' Take the last one.
Pystr+iscool===> ' Pythonis cool! ' Character connection
pystr+ ' +iscool==> ' Python is cool! '
Pystr*2===> ' Pythonpython '/output 2 times
' _ ' *20===> ' ____________________ '/output 20 _
Pystr= ' python
. are cool ' '
Pystr===> ' Python/nis cool '
Print Pystr====>python
are cool
Arrays and meta data
Alist =[1,2,3,4]
alist===>[1,2,3,4]
Alist[0]===>1
alist[2:]===>[3,4]
alist[:3]===>[1,2,3]
Alist[1]=5
alist===>[1,5,3,4]
Tuples cannot be modified
Atuple = (' robots ', 77,93, ' try ')
Atuple===> (' Robots ', 77,93, ' try ')
Atuple[:3]==> (' robots ', 77,93)
Atuple[1]=5//Error
Dictionary//similar map
Adict = {' host ': ' Earch '}
adict[' Port ' = 80
adict===>{' host ': ' Earch ', ' Port ': 80}
Adict.keys () ==>[' host ', ' Port '
adict[' host ']===> ' earch '