青少年软件编程(Python二级)等级考试试卷(2021年6月)
hello*good*morning*
*hello*good*morning
hello*good*morning
*hello*good*morning*
score[3]
score[2]
score.pop(3)
score.pop(2)
['2021', '123', 'Python', 2021]
['2020', '123', 'Python', [2021, '2021']]
['2021', '123', 'Python', [2021, '2021'], 2021]
['2020', '123', 'Python', [2021],2021]
['f', 'i', 'v', 'e', 'r', 's', 't']
['f', 'r', 's', 't']
['f', 'i', 'r', 's']
['f', 'i', 'r', 's', 't']
s.sort()
s.reverse()
print(s)
s.sort(reverse=True)
print(s)
print(sorted(s,reverse=True))
s.sort()
print(s)
True
true
False
false
note
Python
2021
结果错误
246
123123
'123123'
'246'
5
6
10
50
while True:\n a=int(input('年龄:'))\n if(a>=70):\n print('免费')\n elif(a>60 and a<70):\n print('半票')\n else:\n print('全票')
while True:\n a=int(input('年龄:'))\n if(a>=70):\n print('免费')\n elif(a>=60 and a<70):\n print('半票')\n else:\n print('全票')
while True:\n a=int(input('年龄:'))\n if(a>70):\n print('免费')\n elif(a>=60 and a<70):\n print('半票')\n else:\n print('全票')
while True:\n a=int(input('年龄:'))\n if(a>70):\n print('免费')\n elif(a>60 and a<70):\n print('半票')\n else:\n print('全票')
i%2==0:
append(i)
i%2==0
extend(i)
i//2=1
append(i)
i//2=1
extend(i)
字典是可变的无序集合
列表、元组可以相互嵌套使用
字典虽然不能利用下标访问元素,但可以排序
字典属于一对一映射关系的数据类型
同一个元组中,元素的类型必须相同
tuple()函数可以将列表转换为元组
用del就可以删除元组中的元素
列表和元组都是可变数据类型
在while代码块中无论加什么都不能改变死循环
运行结果打印输出10个"Python"语句
这个while循环是一个死循环,会一直打印"Python"
在while代码块中加一行代码num-=1可以改变死循环
The dog is white
hite
ehite
white
yuan={1,2,3}
yuan=[1,2,3]
yuan=(1,2,3)
yuan=<1,2,3>
List1=0 List1
List1="0" List1
List1=[0] List1
List1=List1 [0]
[2, 4, 6]
[1, 2, 3, 1, 2, 3]
[1, 2, 3, 2, 4, 6]
[1, 2, 3, 3, 2, 1]
0,
4,
8,
12,
16,
0,4,8,12,16,
2,
6,
10,
14,
18,
2,6,10,14,18,
if,break
else,break
elif,break
elif,continue
报错
1, 2, 3, 4, 5, 6
(1, 2, 3, 4, 5, 6)
[1, 2, 3, 4, 5, 6]
字典中的值可以是任意类型的数据
字典中的每个元素包含键和值两部分
在同一个字典中,键值必须互不相同
可以通过字典的键找到对应的值,也可以通过值来找到对应的键
顺序结构
分支结构
数据结构
循环结构
{0:"zero",1:"one",2:"two",3:"Three"}
{0:"zero",1:"one",2:"two",3:"three"}
{0:"zero",1:"one",2:"two","3":three}
{0:"zero",1:"one",2:"two",3:"Three",3:"three"}
print(mydict('c'))
print(mydict 'c')
mydict['c']
print(mydict{'c'})
发表评论 取消回复