请把下面的字符串用r'''...'''的形式改写,并用print打印出来:
'\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.'
'\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.'
2018-05-11
等差数列求和公式, 好像是高二的知识, 看来得重新拿起笔了。。。
https://zhinan.sogou.com/guide/detail/?id=316512448222【公式不记得的一起看看】
https://zhinan.sogou.com/guide/detail/?id=316512448222【公式不记得的一起看看】
2018-05-11
def square_of_sum(L):
NL = []
for value in L:
value = value*value
NL.append(value)
return sum(NL)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
NL = []
for value in L:
value = value*value
NL.append(value)
return sum(NL)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2018-05-11
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop (2)
L.pop (2)
print L
和
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop (2)
L.pop ()
print L
都可以
L.pop (2)
L.pop (2)
print L
和
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop (2)
L.pop ()
print L
都可以
2018-05-11
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for index, name in zip(range(1,len(L)+1),L):
print (index, '-', name)
for index, name in zip(range(1,len(L)+1),L):
print (index, '-', name)
def average(*args):
sum = 0.0
i = 1
avg = 0.0
for x in args:
sum = x + sum
avg = sum / i
i = i + 1
return avg
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0.0
i = 1
avg = 0.0
for x in args:
sum = x + sum
avg = sum / i
i = i + 1
return avg
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-05-10
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for key in d:
sum+=d[key];
print sum/len(d)
sum = 0.0
for key in d:
sum+=d[key];
print sum/len(d)
2018-05-10
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.remove('Bart')
L.remove('Paul')
print L
L.remove('Bart')
L.remove('Paul')
print L
2018-05-10
L = [95.5, 85, 59]
L.reverse()
print L
[59, 85, 95.5]
reverse为反转排序
L.reverse()
print L
[59, 85, 95.5]
reverse为反转排序
2018-05-10