这道题的答案检查有问题,即使你输出正确,但是代码中不包含<td style="color:red">也是错的。
换句话说,这道题的答案检查的不是输出正确,而是代码中是否包含了上述字符串,这道题这样是不行的。
换句话说,这道题的答案检查的不是输出正确,而是代码中是否包含了上述字符串,这道题这样是不行的。
2016-09-28
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 int(x) < int(y):
print 10 * int(x) + int(y)
# 根据课程, 用的知识点肯定要用到列表,而不是元组
# 两次循环中的x和y , 单独拎出来其实都是字符串:10 * x 其实就是x这个字符串重复10次, 所有先要把字符串换成整数,再进行运算
for y in ['1', '2', '3', '4', '5', '6', '7', '8', '9']:
if int(x) < int(y):
print 10 * int(x) + int(y)
# 根据课程, 用的知识点肯定要用到列表,而不是元组
# 两次循环中的x和y , 单独拎出来其实都是字符串:10 * x 其实就是x这个字符串重复10次, 所有先要把字符串换成整数,再进行运算
2016-09-28
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
2016-09-28
L = [75, 92, 59, 68]
sum = 0.0
for i in L:
sum = sum + i
print sum / 4
sum = 0.0
for i in L:
sum = sum + i
print sum / 4
2016-09-28
if 条件语句在遇到第一个符合条件的时候, 就跳出当前的循环:
age = 20
if 6 <= age < 18:
print 'teenager'
elif age >= 18:
print 'adult'
else:
print 'kid'
#任务代码
score = 85
if score >= 90:
print 'excellent'
elif score >= 80:
print 'good'
elif score >= 60:
print 'passed'
else:
print 'failed'
age = 20
if 6 <= age < 18:
print 'teenager'
elif age >= 18:
print 'adult'
else:
print 'kid'
#任务代码
score = 85
if score >= 90:
print 'excellent'
elif score >= 80:
print 'good'
elif score >= 60:
print 'passed'
else:
print 'failed'
2016-09-28
score = 55
if score >= 60:
print 'passed'
else:
print 'failed'
if score >= 60:
print 'passed'
else:
print 'failed'
2016-09-28
已采纳回答 / qq_鲸鱼_04046512
m是把L(list)转化为sets-m是s去掉m中的元素,减完只能返回空的set,不可能产生负值;m-s是m去掉s中的元素,还剩一个'Bart';| 是条件运算符,表示p或q,一般来说,空值、缺失值、0等默认是False,其它值是True;False | True 当然是True,所以s的值就是q的值
2016-09-28
这个代码有问题,不能这样写,这样打印出来的结果不是基数,而是:
1
4
9
16
25
36
49
64
81
100
121
144
正确应该这样写:
x=1
a=0
while x<100:
a=x
x=x+2
print a
1
4
9
16
25
36
49
64
81
100
121
144
正确应该这样写:
x=1
a=0
while x<100:
a=x
x=x+2
print a
2016-09-28
L = ['Adam', 'Lisa', 'Bart']
L.insert(1, L.pop())
L.append(L.pop(0))
print L
L.insert(1, L.pop())
L.append(L.pop(0))
print L
2016-09-28
执行L.pop(2)之后,L=['Adam', 'Lisa', 'Bart'],一共3个元素, 再执行L.pop(3), L中没第四个元素,所以会报错
先执行L.pop(3), 再执行L.pop(2)就O了.
先执行L.pop(3), 再执行L.pop(2)就O了.
2016-09-28
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:
print 10*x+y
这哪儿错了吗····
for y in [ 0,1,2,3,4,5,6,7,8,9 ]:
if x < y:
print 10*x+y
这哪儿错了吗····
2016-09-27