文档介绍:Basic
# -*- coding: utf-8 -*-
# python basic
from _abcoll import Iterable
# output
print "hello world","love world"
print 'hello world','love world'
print 'I\'m \"ok\"'
print '\\\t\\'
print r'\\\t\\'
print 'I am learning\npython.'
print '''line1
line2
line3'''
print '100+200=',100+200
print 'hello %s, your score is %d'%('Mart',88)
print ord('A'),chr(65)
print len('ABC')
print "中文"
print len("中文")
# name=raw_input('please input your name:')
# print absolute value of an integer
a=-
if a>0:
print a
else:
print -a
# Bool
print 3>4
print True and False,True or False,not True
# list
classmate=['mark','jone','tick']
print classmate,classmate[2],classmate[-3],classmate[0]
print len(classmate)
('radic')
print classmate
() #delete the last item
print classmate
(1, 'jack') # insert an item
(1) # delete the second item
print classmate
friend=[123,classmate,'pick']
print friend,len(friend)
# tuple
classmate=('mark','jone','tick')
print classmate,classmate[0],classmate[-1]
# if
age=17
if age>18:
print 'adult'
elif age>8:
print 'teenager'
else:
print 'kid'
# for
classmate=['jack','rock','nick']
for name in classmate:
print name
print range(10)
sum_1=0
for i in range(10):
sum_1=sum_1+i
print sum_1
# while
sum_1=0
i=9
while i>0:
sum_1=sum_1+i
i=i-1
print sum_1
# dict
student={'bo':99,'jack':88,'ruck':78,'anny':94,'camy':96}
print (),(),student['jack']
student['jack']=90
print student['jack']
print ('jack'),('jj')
print 'jj'in student,'jack' in student
del student['jack']
print student
print ('ruck'),student
student['tedy']=76
print student
for name in student:
print 'student[%s]=%d'% (name,student[name])
print ()
for name,score in student