正确答案
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,":",d[key]
打印字符串,按照顺序打印,中间使用逗号隔开 按顺序打印
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,":",d[key]
打印字符串,按照顺序打印,中间使用逗号隔开 按顺序打印
2020-02-17
正确答案
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
d[72]='Paul'
print d
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
d[72]='Paul'
print d
2020-02-17
正确答案
# -*- coding: utf-8 -*-
d = {
95:'Adam',85:'Lisa',59:'Bart'
}
print d
# -*- coding: utf-8 -*-
d = {
95:'Adam',85:'Lisa',59:'Bart'
}
print d
2020-02-17
方法一
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(-2)
L.pop()
print L
方法二
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop()
print L
方法三
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
方法四
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(3)
L.pop(2)
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(-2)
L.pop()
print L
方法二
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop()
print L
方法三
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
方法四
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(3)
L.pop(2)
print L
2020-02-17
正确答案
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:',d['Adam']
print 'Lisa:',d['Lisa']
print 'Bart:',d['Bart']
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:',d['Adam']
print 'Lisa:',d['Lisa']
print 'Bart:',d['Bart']
2020-02-17
正确答案
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:
num=x*10+y
print num
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:
num=x*10+y
print num
2020-02-17
正确答案
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x %2==0:
continue
sum+=x
print sum
注意在系代码的时候误输入的空格
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x %2==0:
continue
sum+=x
print sum
注意在系代码的时候误输入的空格
2020-02-17
正确答案
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=x*2
n=n+1
if n>20:
break
print sum
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=x*2
n=n+1
if n>20:
break
print sum
2020-02-17
正确答案
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum=sum+score
print sum / 4
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum=sum+score
print sum / 4
2020-02-17
正确答案
t = ('a', 'b', ('A', 'B'))
print t
t = ('a', 'b', ('A', 'B'))
print t
2020-02-17
正确答案
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
2020-02-17
正确答案
L = ['Adam', 'Lisa', 'Bart']
L.insert(2,'Paul')
print L
L = ['Adam', 'Lisa', 'Bart']
L.insert(2,'Paul')
print L
2020-02-17