a =' pythod' , 非空字符, 为真, or 运算, 判断为真,则不往后面计算, b= ' ', none 字符为假, or 结果取决后一个条件的计算结果, 'world' 为真
2019-06-02
score = 75
if score >= 60:
print 'Bar\'s score is',score
print 'passed'
if score >= 60:
print 'Bar\'s score is',score
print 'passed'
2019-06-01
import math
x1 = 0.0
x2 = 0.0
def quadratic_equation(a, b, c):
if b*b+4*a*c >= 0:
x1 = (-b + math.sqrt(b*b-4*a*c))/(2*a)
x2 = (-b - math.sqrt(b*b-4*a*c))/(2*a)
return x1,x2
else:
return none
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
x1 = 0.0
x2 = 0.0
def quadratic_equation(a, b, c):
if b*b+4*a*c >= 0:
x1 = (-b + math.sqrt(b*b-4*a*c))/(2*a)
x2 = (-b - math.sqrt(b*b-4*a*c))/(2*a)
return x1,x2
else:
return none
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2019-06-01
print("hello, python")
print("hello"+"python")
print("hello"+"python")
2019-05-30
print (45678 + int(0x12fd2))
print ("Learn Python in imooc")
print (100 < 99)
print (0xff == 255)
print ("Learn Python in imooc")
print (100 < 99)
print (0xff == 255)
2019-05-30
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop()
print L
L.pop(2)
L.pop()
print L
2019-05-30
其中 print ('<table border="1">')
border 为边框线条的宽度,添加了之后就会有表格边框
不及格成绩红色基于if判断语句
整个语句运行基于python 3,和python 2有点区别,python 3中使用items,已经没有iteritems这个方法了,请注意哦!
border 为边框线条的宽度,添加了之后就会有表格边框
不及格成绩红色基于if判断语句
整个语句运行基于python 3,和python 2有点区别,python 3中使用items,已经没有iteritems这个方法了,请注意哦!
2019-05-29
输出
print ('<table border="1">')
print ('<tr><th>Name</th><th>Score</th><tr>')
print ('\n'.join(tds))
print ('<table border="1">')
print ('<tr><th>Name</th><th>Score</th><tr>')
print ('\n'.join(tds))
2019-05-29
找到方法了
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
def generate_tr(name, score):
if score<60:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.items()]
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
def generate_tr(name, score):
if score<60:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.items()]
2019-05-29
print([a*100+b*10+c for a in range(1,10) for b in range(0,10) for c in range(1,10) if a==c])
2019-05-29
好像我写了个最笨的
L = ['Adam', 'Lisa', 'Bart']
L[0]='Bart'
L[2]='Adam'
print L
L = ['Adam', 'Lisa', 'Bart']
L[0]='Bart'
L[2]='Adam'
print L
2019-05-29