青少年软件编程(python二级)等级考试试卷-客观题(2022年12月)
{1: '小明', 2: '小白', 3: '小红', 4: '小兰'}
{1: '小明', 2: '小白', 3: '小兰', 4: '小红'}
{1: '小白', 2: '小名', 3: '小兰', 4: '小红'}
{1: '小明', 2: '小红', 3: '小兰', 4: '小白'}
s=1 2 3 5 6… 100的值
s=1-2 3-4 5-6 …-100的值
s=1 2 3 4 5 6… 101的值
s=1-2 3-4-5-6-…-101的值
print(game_name[-4] game_where[-1] game_what[0])
print(game_name[2] game_where[6] game_what[0])
print(game_name[3] game_where[6] game_what[1])
print(game_name[-4] game_where[5] game_what[1])
st
stu
s
t
s
t
u
score[跳绳]=95
score['跳绳']=95
score[0]=95
score['0']=95
[[2, 4, 6],[2, 4, 6]]
[2, 4, 6, 2, 4, 6]
[4, 16, 36]
[4, 8, 12]
[3,9,5]
[7,3,9,5]
[3,9,5,7]
[7,9,5]
['魔方', '拼图', ['积木']]
['魔方', '拼图', '积木']
['积木', '魔方', '拼图']
'魔方', '拼图', '积木'
4
5
6
7
gift.pop('糖果':10)
gift.pop('糖果')
gift.remove('糖果':10)
gift.remove('糖果')
list1.sort()
list1 = sorted(list1,reverse=True)
list1.sort(reverse=True)
list1.sort()
list1 = list1[-1::-1]
min(ls):找出ls中最小元素
ls.remove(x):删除ls中所有x元素
ls.index(x):返回元素x在列表中的下标
ls.copy():生成一个新列表,复制ls的所有元素
Python
Pytho
ython
Python语言程序
cat dog mouse dog cat dog
2 dog mouse dog cat dog
mouse mouse dog mouse mouse dog cat dog
mouse dog mouse dog cat dog
2
0
程序报错
3
if语句通常用于重复执行某一段程序
while语句通常用于执行条件判断
在Python中可以使用do..while循环
break语句可以跳出for和while的循环体
8
9
10
11
3
7
5
6
0
1
True
False
[1,2]
[4,6]
[1,2,3,4]
[3,4]
136.0
135.0
142.0
140.0
4
5
6
7
print(d['奥运奖牌']['金牌'])
print(d['金牌'])
print(d['奥运奖牌'][-1])
print(d['金牌'][1])
[89, 43, 22, 8, 7, 5, 2, 1]
(89, 43, 22, 8, 7, 5, 2, 1)
[1, 2, 5, 7, 8, 22, 43, 89]
(1, 2, 5, 7, 8, 22, 43, 89)
发表评论 取消回复