# -*- coding: utf-8 -*-
d = {
95:'Adam',
85:'Lisa',
59:'Bart'
}
d = {
95:'Adam',
85:'Lisa',
59:'Bart'
}
2018-05-27
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:'
print d.get('Adam')
print 'Lisa:'
print d.get('Lisa')
print 'Bart:'
print d.get('Bart')
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:'
print d.get('Adam')
print 'Lisa:'
print d.get('Lisa')
print 'Bart:'
print d.get('Bart')
2018-05-27
for x in [ '1','2','3','4','5','6','7','8','9' ]:
for y in [ '1','2','3','4','5','6','7','8','9']:
if x >= y:
continue
print x + y
for y in [ '1','2','3','4','5','6','7','8','9']:
if x >= y:
continue
print x + y
2018-05-27
sum = 0
x = 0
while True:
...x = x + 1
...if x > 100:
......break
...if x%2==0:
......continue
...sum+=x
print sum
x = 0
while True:
...x = x + 1
...if x > 100:
......break
...if x%2==0:
......continue
...sum+=x
print sum
2018-05-26
sum = 0
x = 1
n = 1
while True:
... if n<=20:
...... sum+=x
...... x=x*2
... else:
...... break
... n+=1
print sum
#1048575
x = 1
n = 1
while True:
... if n<=20:
...... sum+=x
...... x=x*2
... else:
...... break
... n+=1
print sum
#1048575
2018-05-26
sum = 0
x = 1
while x<=100:
if x%2==1:
sum+=x
x+=1
print sum
x = 1
while x<=100:
if x%2==1:
sum+=x
x+=1
print sum
2018-05-26
# -*- coding: utf-8 -*-
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2018-05-26
sum = 0
x = 0
while True:
x = x + 1
if x % 2 == 0:
continue
sum = sum + x
if x >98:
break
print sum
break 结束的时候要小心一点 ,习惯了for
x = 0
while True:
x = x + 1
if x % 2 == 0:
continue
sum = sum + x
if x >98:
break
print sum
break 结束的时候要小心一点 ,习惯了for
2018-05-26
a=[12.34,9.08,73.1]
def func(n):
if n<3:
print(3.14*a[n]**2)
n=n+1
return func(n)
func(0)
def func(n):
if n<3:
print(3.14*a[n]**2)
n=n+1
return func(n)
func(0)
2018-05-26
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2 == 0:
continue
sum += x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2 == 0:
continue
sum += x
print sum
2018-05-26
print [100*x+10*y+z for x in range(1,10) for y in range(0,10) for z in range(1,10) if (x==z)]
L = []
for m in range(1,10):
for n in range(0,10):
for o in range(1,10):
if(m==o):
L.append(100*m+ 10*n+o)
print L
L = []
for m in range(1,10):
for n in range(0,10):
for o in range(1,10):
if(m==o):
L.append(100*m+ 10*n+o)
print L
2018-05-26
import math
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 'error'
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
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 'error'
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2018-05-25
x1 = 1
d = 3
n = 100
xn = x1+(n-1)*d
s = n*(x1+xn)/2
print (s)
需要计算多少项之和,只需修改X1 D N 数值即可
d = 3
n = 100
xn = x1+(n-1)*d
s = n*(x1+xn)/2
print (s)
需要计算多少项之和,只需修改X1 D N 数值即可
2018-05-25
L = ['Adam',95.5,'Lisa',95,'Bart',59]
print L
运行成功 输出错误
print L
运行成功 输出错误
2018-05-25