for x in range(1,10):
for y in range(10):
if x >= y:
continue
print(x+y)
for y in range(10):
if x >= y:
continue
print(x+y)
2020-04-04
sum=0
x=1
while True:
sum += x
x += 1
if x > 21:
break
print(sum)
x=1
while True:
sum += x
x += 1
if x > 21:
break
print(sum)
2020-04-04
sum = 0.0
for i in range(1,100):
if i %2 == 1:
sum += i
print(sum)
for i in range(1,100):
if i %2 == 1:
sum += i
print(sum)
2020-04-04
x=0
L=[]
sum=0.0
while x < 100:
x += 1
L.append(x)
for i in L:
if i%2==1:
sum += i
print (sum)
L=[]
sum=0.0
while x < 100:
x += 1
L.append(x)
for i in L:
if i%2==1:
sum += i
print (sum)
2020-04-03
L = [75,92,59,68]
sum = 0.0
for i in range(len(L))
sum += L[i]
aver = sum / len(L)
print(aver)
sum = 0.0
for i in range(len(L))
sum += L[i]
aver = sum / len(L)
print(aver)
2020-04-03
x=4.5678e4+0x12fd2
print x
//这里自动会变成浮点数
print 45678+0x12fd2
//这样的输出是整数
print "Learn Python in imooc"
print 100 < 99
print 0xff == 255
//比大小,判等,结果自动返回布尔值(True False)
print x
//这里自动会变成浮点数
print 45678+0x12fd2
//这样的输出是整数
print "Learn Python in imooc"
print 100 < 99
print 0xff == 255
//比大小,判等,结果自动返回布尔值(True False)
2020-04-03
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
因为不存在运算问题,所以直接把数字做为字符串进行输出,更简单更好理解.
2020-04-03
print45678+int('0x12fd2,16')
print'Learn Python in imooc'
print100<99
printOxff==255
大神看看哪错了
print'Learn Python in imooc'
print100<99
printOxff==255
大神看看哪错了
2020-04-02
import math
def quadratic_equation(a, b, c):
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
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
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
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2020-03-31
for x in range(1,10):
for y in range(1,10):
if x < y:
print x * 10 + y
for y in range(1,10):
if x < y:
print x * 10 + y
2020-03-31