sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==1:
sum+=x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==1:
sum+=x
print sum
2018-05-14
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2018-05-14
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-14
import math
def quadratic_equation(a, b, c):
d=(b*b)-(4*a*c)
if d<0:
return 'None'
elif d==0:
x=-b/(2*a)
return x
else:
x1=(-b+math.sqrt(d))/(2*a)
x2=(-b-math.sqrt(d))/(2*a)
return x1,x2
def quadratic_equation(a, b, c):
d=(b*b)-(4*a*c)
if d<0:
return 'None'
elif d==0:
x=-b/(2*a)
return x
else:
x1=(-b+math.sqrt(d))/(2*a)
x2=(-b-math.sqrt(d))/(2*a)
return x1,x2
2018-05-14
python运行结果应该是这样的
<table border="1">
<tr><th>Name</th><th>Score</th><tr>
<tr><td>Adam</td><td>95</td></tr>
<tr><td>Lisa</td><td>85</td></tr>
<tr><td>Bart</td><td style="color:red">59</td></tr>
</table>
只有保存为***。html格式,再用浏览器打开才是表格这个模样。
<table border="1">
<tr><th>Name</th><th>Score</th><tr>
<tr><td>Adam</td><td>95</td></tr>
<tr><td>Lisa</td><td>85</td></tr>
<tr><td>Bart</td><td style="color:red">59</td></tr>
</table>
只有保存为***。html格式,再用浏览器打开才是表格这个模样。
2018-05-14
def square_of_sum(L):
sum=0
for l in L:
sum+=l*l
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum=0
for l in L:
sum+=l*l
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2018-05-14
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for score in d.itervalues():
sum+=score
print sum/len(d)
sum = 0.0
for score in d.itervalues():
sum+=score
print sum/len(d)
2018-05-14