d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
for name in d:
print(d.get(name))
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
for name in d:
print(d.get(name))
2021-09-16
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49,
'Gaven':86
}
print(d)
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49,
'Gaven':86
}
print(d)
2021-09-16
# Enter a code
s1='ABC'
s2='123'
s3='xyz'
for x in s1:
for y in s2:
for z in s3:
print(x+y+z)
s1='ABC'
s2='123'
s3='xyz'
for x in s1:
for y in s2:
for z in s3:
print(x+y+z)
2021-09-16
# Enter a code
T=(100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print(T.count(100))
T=(100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print(T.count(100))
2021-09-16
# Enter a code
a=1
b=1
while a>0 and a<=10:
b=b*a
a=a+1
print(b)
a=1
b=1
while a>0 and a<=10:
b=b*a
a=a+1
print(b)
2021-09-15
最新回答 / qq_棠梨煎雪故人来_03907185
你这应该是从c啊之类的语言里面学的习惯吧,当你for i in L的时候,它迭代的不是下标1、2、3,它迭代的是里面的元素,在这句里迭代的是[1,2,3]和后面的两个列表。所以你这句话按机器理解的是area*=L[[1,2,3][5,3,2]],很明显,这是错的。所以这个错误报告给你说list的下标应该是整数或者是划分,不能是个列表。想达到你想要的效果,就for i in range(len(L)吧,但就算是按下标算,你思路也是错的。
2021-09-15
最新回答 / 鹏鹏1209393
template='{} {} {} ,{} {} {}.' l='life' i='is' s='short' y='you' n='need' p='python' result=template.format(l,i,s,y,n,p)
2021-09-15
最新回答 / weixin_慕容1556897
有关系!例如: “{0}{2}{1}".format(100,200,300) 输出结果为:100 300 200 “{0}{1}{2}".format(100,200,300) 输出结果为:100 200 300 “{ }{ }{ }".format(100,200,300) 输出结果为:100 200 300 默认顺序输出
2021-09-15
L=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L[0]='Ellena'
L[1]='Alice'
L[2]= 'Candy'
L[3]='David'
L[4]='Bob'
print(L)
L[0]='Ellena'
L[1]='Alice'
L[2]= 'Candy'
L[3]='David'
L[4]='Bob'
print(L)
2021-09-15
name=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name.insert(5,'Gen')
name.insert(6,'Phoebe')
name.append('Zero')
print(name)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L.append('Zero')
L.insert(5, 'Phoebe')
L.insert(5, 'Gen')
print(L)
name.insert(5,'Gen')
name.insert(6,'Phoebe')
name.append('Zero')
print(name)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L.append('Zero')
L.insert(5, 'Phoebe')
L.insert(5, 'Gen')
print(L)
2021-09-15
# Enter a code
num=0
L = ['Alice', 66, 'Bob', True, 'False', 100]
for a in L:
num=num+1
if num%2==0:
continue
print(a)
num=0
L = ['Alice', 66, 'Bob', True, 'False', 100]
for a in L:
num=num+1
if num%2==0:
continue
print(a)
2021-09-15
# Enter a code
s1="ABC"
S2="123"
S3="XYZ"
for a in s1:
for b in S2:
for c in S3:
print(a+b+c)
s1="ABC"
S2="123"
S3="XYZ"
for a in s1:
for b in S2:
for c in S3:
print(a+b+c)
2021-09-15
num=0
sum=0
while True:
if num>1000:
break
num=num+2
sum=num+sum
print(sum)
sum=0
while True:
if num>1000:
break
num=num+2
sum=num+sum
print(sum)
2021-09-15
# Enter a code
#coding:utf-8
age=21
if age>=18:
print('adult')
elif age>=6:
print('tennager')
elif age>=3:
print('kid')
else:
print('adult')
#coding:utf-8
age=21
if age>=18:
print('adult')
elif age>=6:
print('tennager')
elif age>=3:
print('kid')
else:
print('adult')
2021-09-15