GESP Python 4级 2025.03
2025年春节有两件轰动全球的事件,一个是DeepSeek横空出世,另一个是贺岁片《哪吒2》票房惊人,入了全球票房榜。下面关于DeepSeek与《哪吒2》的描述成立的是( )。
《哪吒2》是一款新型操作系统
DeepSeek是深海钻探软件
《哪吒2》可以生成新的软件
DeepSeek可以根据《哪吒2》的场景生成剧情脚本
对整型变量N,如果它能够同时被3和5整除,则输出N是含有至少两个质因数 。如果用流程图来描述处理过程,则输出语句应该在哪种图形框中( )。
圆形框
椭圆形框
平行四边形框
菱形框
执行下面Python代码后,输出的结果是?
lst = [{'num': i} for i in range(3)]
lst[1]['num'] = 99
print(lst)
[{'num': 0}, {'num': 1}, {'num': 2}]
[{'num': 0}, {'num': 99}, {'num': 2}]
所有字典的 'num' 都变为 99
报错
执行下面Python代码后,输出的结果是?
keys = ['a', 'b']
values = [[1], (2,)]
d = {k: v for k, v in zip(keys, values)}
d['a'].append(3)
print(d['a'])
[1]
(2,)
[1, 3]
报错
执行下面Python代码后,输出的结果是?
def append_value(value, container=[]):
container.append(value)
return container
result1 = append_value(1)
result2 = append_value(2)
result3 = append_value(3, [])
print(result1, result2, result3)
[1] [2] [3]
[3] [3] [3]
[1] [1, 2] [3]
[1, 2] [1, 2] [3]
以下哪个函数调用是合法的?
def func(a, b, c=0):
print(a + b + c)
func(1, b=2, 3)
func(a=1, 2, c=3)
func(1, 2)
func(b=1, a=2, 3)
执行下面Python代码后,输出的结果是?
def swap(a, b):
a, b = b, a
return a, b
x, y = 1, 2
swap(x, y)
print(x, y)
1 2
2 1
(2, 1)
报错
执行下面Python代码后,输出的结果是?
def outer():
n = 0
def inner():
nonlocal n
n += 1
return n
return inner
f = outer()
print(f(), f(), f())
1 2 3
1 1 1
3 3 3
报错
以下哪个函数调用会返回 [2, 4, 6]?
def process(lst, func):
return [func(x) for x in lst]
nums = [1, 2, 3]
process(nums, lambda x: x % 2)
process(nums, lambda x: x + 1)
process(nums, lambda x: x ** 2)
process(nums, lambda x: x * 2)
执行下面Python代码时,哪条调用会报错?
def func(a, *, b, c):
pass
func(1, b=2, c=3)
func(1, 2, c=3)
func(a=1, b=2, c=3)
func(1, c=3, b=2)
