L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop( )
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop( )
L.pop( )
print L
等等几种方法都可以 就像数学的排列组合一样
L.pop(2)
L.pop(2)
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop( )
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop( )
L.pop( )
print L
等等几种方法都可以 就像数学的排列组合一样
2018-09-29
import math
def quadratic_equation(a, b, c):
f=b**2-4*a*c
if f>=0:
y1=(-b+math.sqrt(f))/(2*a)
y2=(-b-math.sqrt(f))/(2*a)
return y1,y2
else:
return
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
f=b**2-4*a*c
if f>=0:
y1=(-b+math.sqrt(f))/(2*a)
y2=(-b-math.sqrt(f))/(2*a)
return y1,y2
else:
return
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2018-09-29
x1 = 1
d = 3
n = 100
x100 = x1+d*99
s = (x1+x100)*((x100-x1)/d+1)/2
print s
得知道数学公式啊 !
和=(首相+末项)*项数/2
项数=(末项-首相)/公差+1
d = 3
n = 100
x100 = x1+d*99
s = (x1+x100)*((x100-x1)/d+1)/2
print s
得知道数学公式啊 !
和=(首相+末项)*项数/2
项数=(末项-首相)/公差+1
2018-09-28
print(45678+0x12fd2)
print('Learn Python in imooc')
print(100<99)
print(0xff==255)
print('Learn Python in imooc')
print(100<99)
print(0xff==255)
2018-09-28
print(45678+0x12fd2)
print('Learn Python in imooc')
print(100<99,0xff==255)
print('Learn Python in imooc')
print(100<99,0xff==255)
2018-09-27
import math
def yiyuanerci(a,b,c):
x1=(-b+math.sqrt(b**2-4*a*c)) / (2*a)
x2=(-b-math.sqrt(b**2-4*a*c)) / (2*a)
return x1,x2
print yiyuanerci(2,3,0)
print yiyuanerci(1,-6,5)
def yiyuanerci(a,b,c):
x1=(-b+math.sqrt(b**2-4*a*c)) / (2*a)
x2=(-b-math.sqrt(b**2-4*a*c)) / (2*a)
return x1,x2
print yiyuanerci(2,3,0)
print yiyuanerci(1,-6,5)
2018-09-27
a = 45678 ; b = 0x12fd2 ; print (a+b)
print 'Learn Python in imooc.'
print (100 < 99); print (0xff == 255)
print 'Learn Python in imooc.'
print (100 < 99); print (0xff == 255)
2018-09-26
#Enter a code
a=45678+0x12fd2
b='Learn Python in imooc'
c=(100<99)
d=(0xff==255)
print(a)
print(b)
print(c)
print(d)
a=45678+0x12fd2
b='Learn Python in imooc'
c=(100<99)
d=(0xff==255)
print(a)
print(b)
print(c)
print(d)
2018-09-26
sum = 0
x = 1
n = 1
while True:
sum+=x;
x*=2;
n+=1;
if n>20:
break;
print sum
x = 1
n = 1
while True:
sum+=x;
x*=2;
n+=1;
if n>20:
break;
print sum
2018-09-26
L = ['Adam', 'Lisa', 'Bart']
t=L[0];
L[0]=L[2];
L[2]=t;
print L
t=L[0];
L[0]=L[2];
L[2]=t;
print L
2018-09-26
def firstCharUpper(s):
return s.title()
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s.title()
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2018-09-26
使用input语句并对参数进行赋值,得到的值都是字符串而非数字,什么原因呢?说是字符串吧它又能排序就是不能计算
2018-09-26
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-09-25