青少年软件编程(Python四级)等级考试试卷(2022年9月)
时间复杂度
空间复杂度
难易度
健壮性
0
2
3
1
float() abs()
pow() format()
ord() chr()
round() import()
int( )
float( )
bool( )
class( )
运行下列这段程序,正确的输出结果是?(?)
LS = ["apple", "red", "orange"]
def funb(a):
LS.append(a)
funb("yellow")
print(LS)
["apple","red","orange"]
["apple","red","orange","yellow"]
[]
["yellow"]
102 2
24 10
24 2
102 10
函数可以没有返回值,也可以有一个或多个返回值
函数定义中最多含有一个return语句
在函数定义中用return语句时,至少给一个返回值
函数中 return语句只能放在函数定义的最后
esrever
reverse
rsereve
rseveer
import pandas
import pandas as p
import pandas *
from pandas import *
sleep(3600)
time.time(60)
time.asctime(1)
time.sleep(60)
分解、解决、合并
分解、解决
合并、解决
合并、解决、分解
分治法
贪心法
回溯法
动态规划法
4 5
10 5
4 15
10 15
出错
死循环
here
here
there
f(,2)
f(1,2)
f(1)
f(1,)
5 6
6 5
2 3
3 2
['Pear','Apple']
['Pear','Apple','Apple']
['Apple','Pear','Apple','Apple']
['Apple']
打印输出:感谢张三对公司的贡献!
然后报错:TypeError: ThankYou() missing 1 required positional argument: 'name'
打印输出:
感谢张三对公司的贡献!
感谢对公司的贡献!
无法输出。
需要增加main函数才能正确运行。
枚举
递归
解析
分治
n Sum(n-1)
n Sum(n 1)
n Sum(n 2)
n Sum(n-2)
明确的边界条件
边界值
循环语句
终止条件
100
110
120
130
递归算法不涉及高深的数学知识,比较容易理解。
递归过程一般通过函数或子过程来实现。
递归算法是递推分解问题,然后再将最简单情况的解回归成大问题的解。
存在既可以用递归算法解决,也可以用递推算法解决的问题。
发表评论 取消回复