L = [75, 92, 59, 68]
sum = 0.0
for a in L:
sum+=a;
print sum / 4
总有写分号的习惯,我次奥。
sum = 0.0
for a in L:
sum+=a;
print sum / 4
总有写分号的习惯,我次奥。
2015-03-16
t = ('a', 'b', ('A', 'B'))
print t
list === nsmutablearray, tuple = nsarray
print t
list === nsmutablearray, tuple = nsarray
2015-03-16
L = ['Adam', 'Lisa', 'Bart']
L[-1] = 'Adam'
L[0] = 'Bart'
print L
L[-1] = 'Adam'
L[0] = 'Bart'
print L
2015-03-16
classmates = ['Adam',95.5,'Lisa',85,'Bart',59]
print classmates
print classmates
2015-03-16
N = 10
x = 0
while x < N:
print x
x = x + 1
这段代码有问题,输出结果是0-9,而题干要求是0-10
应该改成while x <= N
x = 0
while x < N:
print x
x = x + 1
这段代码有问题,输出结果是0-9,而题干要求是0-10
应该改成while x <= N
2015-03-16
# -*- coding: utf-8 -*-
d = {
95:['Adam','xxx'],
85:['Lisa'],
59:['Bart']
}
用List可以解决重复分数的问题吧?
只不过答案提交不过去
d = {
95:['Adam','xxx'],
85:['Lisa'],
59:['Bart']
}
用List可以解决重复分数的问题吧?
只不过答案提交不过去
2015-03-16
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
continue
s.add(x)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
continue
s.add(x)
print s
2015-03-15
Python中串联字符串的操作符有两个,一个是"+", 一个是",", "+"不能用来串联非字符串,而","可以!而且","还会输出一个空格
2015-03-15
对list类型,索引迭代用enumate()方法,对dict类型,索引迭代用items()方法,返回的一个是内容为tuple的list.
2015-03-15