青少年软件编程(python三级)等级考试试卷-客观题(2023年9月)
print(things)
print(things[:4])
print(things[4:])
print(things[5:8])
tscores[0][2]
tscores[1][1]
tscores[0[2]]
tscores[1[1]]
max(tscores[1])
max(tscores[1][1:])
tscores[1].max()
tscores[1][1: ].max()
在执行代码前,必须要先新建一个"jts.txt"的文件
在文件"jts.txt"中,所有相邻诗句之间将发生换行
f.write(','.join(gs) '\\n')也可以用f.write('\\n'.join(gs) ',')替换,显示结果是相同的
该段代码的主要功能是将列表gs中的四句古诗写入到"jts.txt"文件中,诗句之间以逗号连成一行
可以用Python内置的open()函数打开文件
对文件进行读取操作,我们可以用write()函数
对文件进行写入操作,我们可以用close()函数
关闭文件可以用read()函数
"9"
9
"10"
10
128
256
28
56
int("0b1010",10)
int("1010",10)
int("0o50",10)
int("80",8)
abs(-6)
int(6.88)
round(5.55)
min(float(6),9,8,7)
我爱中国2023
程序结束
错误
程序结束
我爱中国2023
错误
3
4
5
6
2, 4, 5, 1, 6, 3, 7, 8
6, 5, 8, 4, 7, 3, 2, 1
5, 6, 4, 8, 2, 7, 3, 1
5, 6, 4, 8, 7, 3, 2, 1
解析算法
枚举算法
对分查找
选择排序
abs()函数的功能是取一个整数的绝对值
abs(0)的运行结果是0
abs(3.0)的运行结果是3.0
abs(-3)的运行结果是3
4, 1
(4, 1)
1, 4
(1, 4)
print(all(['1','2','3']))
print(all(()))
print(all(('1','2','3','4','5')))
print(all(['1','2','3','']))
[2, -3, -5, -6, -1, 4, 9]
(2, -3, -5, -6, -1, 4, 9)
[2, 4, 9]
(2, 4, 9)
'r'以只读方式打开文件,如果文件不存在,则会提示错误
'w'以写入的方式打开文件,如果文件不存在,则会提示错误
'a'打开文件,并将新内容写入到已有内容之后
'r '以读、写方式打开文件
'A' 'Z'
'AZ'
'A''Z'
"AZ"
23
23.0
23.8
23.792
bool([])
bool("0")
bool(None)
bool(range(0))
hello python_
hello pythonhello python
hello python_hello pythonhello python
hello python_hello python hello python
hello python_hellopythonhellopython
(0, 1, 5, 6, 7, 9, 15)
(15, 9, 7, 6, 5, 1, 0)
[0, 1, 5, 6, 7, 9, 15]
[15, 9, 7, 6, 5, 1, 0]
发表评论 取消回复