# -*- coding: utf-8 -*-
print '#例1'
age=20
if age >= 18:
print 'your age is',age
print 'adult'
print 'END'
print '\n#任务'
score = 75
if score >= 60:
print 'passed'
print 'END'
print '#例1'
age=20
if age >= 18:
print 'your age is',age
print 'adult'
print 'END'
print '\n#任务'
score = 75
if score >= 60:
print 'passed'
print 'END'
2018-05-23
# -*- coding: utf-8 -*-
t_first=('a','b',['A','B'])
L=t_first[2]
print 'L=',L #取出tuple的值
L[0]='X'
L[1]='Y'
print '\nL=',L
print 't_first=',t_first #更改tuple中list元素的值,可更改
L_error=t_first[0]
L_error=['c']
print '\nt_first=',t_first #更改tuple中非list元素的值,不可更改
t = ('a', 'b', ('A', 'B'))
print t
t_first=('a','b',['A','B'])
L=t_first[2]
print 'L=',L #取出tuple的值
L[0]='X'
L[1]='Y'
print '\nL=',L
print 't_first=',t_first #更改tuple中list元素的值,可更改
L_error=t_first[0]
L_error=['c']
print '\nt_first=',t_first #更改tuple中非list元素的值,不可更改
t = ('a', 'b', ('A', 'B'))
print t
2018-05-23
# -*- coding: utf-8 -*-
#空tuple
t0=()
print 't=',t0
#一个元素
t1=(2,)
print 't1=',t1
#多元素
tn=(1,2,3,4,5)
print 'tn=',tn
t = ('Adam',)
print t
#空tuple
t0=()
print 't=',t0
#一个元素
t1=(2,)
print 't1=',t1
#多元素
tn=(1,2,3,4,5)
print 'tn=',tn
t = ('Adam',)
print t
2018-05-23
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop()
print L
L.pop(2)
L.pop()
print L
2018-05-23
print(45678+0x12fd2)
print("Learn Python in imooc")
print(100<99,0xff==255)
print("Learn Python in imooc")
print(100<99,0xff==255)
2018-05-23
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
2018-05-23
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
print s
2018-05-23
x1 = 1
d = 3
n = 100
x100 = (n-1)*d+x1
n = 1
s = 0
while n <= 100:
s += (n-1)*d+x1
n += 1
print(s)
d = 3
n = 100
x100 = (n-1)*d+x1
n = 1
s = 0
while n <= 100:
s += (n-1)*d+x1
n += 1
print(s)
2018-05-23
str = "hello,python"
print(str)
print("hello,python")
print(str)
print("hello,python")
2018-05-23
# -*- coding: UTF-8 -*-
S = ['Adam', 'Lisa', 'Bart']
#替换元素,即更新列表
S[2]='pual'
print 'S=',S
L = ['Adam', 'Lisa', 'Bart']
L[0],L[2]=L[2],L[0]
print '\nL=',L
S = ['Adam', 'Lisa', 'Bart']
#替换元素,即更新列表
S[2]='pual'
print 'S=',S
L = ['Adam', 'Lisa', 'Bart']
L[0],L[2]=L[2],L[0]
print '\nL=',L
2018-05-23
# -*- coding: UTF-8 -*-
S = ['Adam', 'Lisa', 'Paul', 'Bart']
#删除最后一个
S.pop()
print 'S=',S
#删除任意位置元素
S.pop(2)
print '\nS=',S,'\n'
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
#此时L=['Adam', 'Lisa', Bart'],Bart的索引变为2
L.pop(2)
print L
S = ['Adam', 'Lisa', 'Paul', 'Bart']
#删除最后一个
S.pop()
print 'S=',S
#删除任意位置元素
S.pop(2)
print '\nS=',S,'\n'
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
#此时L=['Adam', 'Lisa', Bart'],Bart的索引变为2
L.pop(2)
print L
2018-05-23