L = ["Adam", 95.5, "Lisa", 85, "Bart", 59]
print L
print L
2018-04-25
例如Python自带的 int() 函数,其实就有两个参数,我们既可以传一个参数,又可以传两个参数:
>>> int('123')
123
>>> int('123', 8)
83
求解啥意思
>>> int('123')
123
>>> int('123', 8)
83
求解啥意思
2018-04-25
#Enter a code
a = 45678;
b = 0x12fd2;
c = a + b;
print c;
print "Learn Python in imooc";
print 100<99;
print 0xff == 255;
a = 45678;
b = 0x12fd2;
c = a + b;
print c;
print "Learn Python in imooc";
print 100<99;
print 0xff == 255;
2018-04-25
import math
def quadratic_equation(a, b, c):
z=math.sprt(b*b-4*a*c)
if z>=0:
x1=(-b+z)/(2*a)
x2=(-b-z)/(2*a)
return x1,x2
else:
return
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
z=math.sprt(b*b-4*a*c)
if z>=0:
x1=(-b+z)/(2*a)
x2=(-b-z)/(2*a)
return x1,x2
else:
return
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2018-04-24
def average(*args):
n=0.0
s=0.0
for a in args:
s+=a
n+=1
if n==0.0:
return 0.0
else:
return s/n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
n=0.0
s=0.0
for a in args:
s+=a
n+=1
if n==0.0:
return 0.0
else:
return s/n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-04-24
def greet(x='world'):
print 'Hello,',x,'.'
print 'Hello,',x,'.'
2018-04-24