# -*- encoding=utf-8 -*-
import math as m
def do_quadratic_equation(a,b,c):
dt = b*b-4*a*c
if dt < 0 :
return "b*b-4ac不能小于0"
else:
x1 = (-b+m.sqrt(dt))/(2*a)
x2 = (-b-m.sqrt(dt))/(2*a)
return x1,x2
import math as m
def do_quadratic_equation(a,b,c):
dt = b*b-4*a*c
if dt < 0 :
return "b*b-4ac不能小于0"
else:
x1 = (-b+m.sqrt(dt))/(2*a)
x2 = (-b-m.sqrt(dt))/(2*a)
return x1,x2
2018-04-13
# -*- coding=utf-8 *-*
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
# tup 元祖 ()
for tup in s :
print tup[0] + ":" + str(tup[1])
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
# tup 元祖 ()
for tup in s :
print tup[0] + ":" + str(tup[1])
2018-04-13
# -*- coding: utf-8 -*-
months = set(['Jan','Feb','Mar','Apr','May','Jane','July','Aug','Sep','Oct','Nov','Dec'])
x1 = "Jan"
x2 = "jan"
print ('x1:'),
if x1 in months:
print "ok"
else:
print "error"
print ('x2:'),
if x2 in months:
print "ok"
else:
print "error"
#这要求的输出格式啃爹啊!
months = set(['Jan','Feb','Mar','Apr','May','Jane','July','Aug','Sep','Oct','Nov','Dec'])
x1 = "Jan"
x2 = "jan"
print ('x1:'),
if x1 in months:
print "ok"
else:
print "error"
print ('x2:'),
if x2 in months:
print "ok"
else:
print "error"
#这要求的输出格式啃爹啊!
2018-04-13
for x in range(1,10):
for y in range(10):
if(x<y):
print ('%d%d' % (x,y))
else:
continue
这样比较好
for y in range(10):
if(x<y):
print ('%d%d' % (x,y))
else:
continue
这样比较好
2018-04-13
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
rtnSet = set([])
for name in s :
name = name.lower()
rtnSet.add(name)
print ('adam' in rtnSet)
print ('bart' in rtnSet)
rtnSet = set([])
for name in s :
name = name.lower()
rtnSet.add(name)
print ('adam' in rtnSet)
print ('bart' in rtnSet)
2018-04-13
sum = 0
x = 1
n = 1
while True:
x=2**(n-1)
sum=sum+x
if n==20:
break
n=n+1
print sum
x = 1
n = 1
while True:
x=2**(n-1)
sum=sum+x
if n==20:
break
n=n+1
print sum
2018-04-13
for x in [1,2,3,4,5,6,7,8,9 ]:
for y in [0,1,2,3,4,5,6,7,8,9]:
if x<y:
n=10*x+y
print n
print n的位置不对出来的结果就不一样,果然python对空格的要求严格
for y in [0,1,2,3,4,5,6,7,8,9]:
if x<y:
n=10*x+y
print n
print n的位置不对出来的结果就不一样,果然python对空格的要求严格
2018-04-13
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=x*2
n=n+1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+x
x=x*2
n=n+1
if n>20:
break
print sum
2018-04-13
for x in range(1,10):
for y in range(1,10):
if x < y:
print int(str(x)+str(y))
for y in range(1,10):
if x < y:
print int(str(x)+str(y))
2018-04-12
d={
95:'Adam',
85:'Lisa',
59:'Bart'
}
95:'Adam',
85:'Lisa',
59:'Bart'
}
2018-04-12
print(45678+0x12fd2)
print("Learn Python in imooc")
print(0xff==255)
print("Learn Python in imooc")
print(0xff==255)
2018-04-12