#G4208. [GESP202503 四级] 客观题

    ID: 189 Type: Objective Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>GESP Python编程能力等级认证

[GESP202503 四级] 客观题

单选题

1.2025年春节有两件轰动全球的事件,一个是DeepSeek横空出世,另一个是贺岁片《哪吒2》票房惊人,入了全球票房榜。下面关于DeepSeek与《哪吒2》的描述成立的是( )。

{{ select(1) }}

  • 《哪吒2》是一款新型操作系统
  • DeepSeek是深海钻探软件
  • 《哪吒2》可以生成新的软件
  • DeepSeek可以根据《哪吒2》的场景生成剧情脚本

2.对整型变量N,如果它能够同时被3和5整出,则输出 N是含有至少两个质因数。如果用流程图来描述处理过程,则输出语句应该在哪种图形框中( )。

{{ select(2) }}

  • 圆形框
  • 椭圆形框
  • 平行四边形框
  • 菱形框

3.执行下面Python代码后,输出的结果是?( )

{{ select(3) }}

  • [{"num": 0}, {"num": 1}, {"num": 2}]
  • [{"num": 0}, {"num": 99}, {"num": 2}]
  • 所有字典的 'num' 都变为 99
  • 根错

4.执行下面Python代码后,输出的结果是?( )

{{ select(4) }}

  • [1]
  • (2)
  • [1, 3]
  • 报错

5.执行下面Python代码后,输出的结果是?()

{{ select(5) }}

  • [1] [2] [3]
  • [3] [3] [3]
  • [1] [1, 2] [3]
  • [1, 2] [1, 2] [3]

6.以下哪个函数调用是合法的?()

def func(a, b, c=0): print(a + b + c)

{{ select(6) }}

  • func(1, b=2, 3)
  • func(a=1, 2, c=3)
  • func(1, 2)
  • func(b=1, a=2, 3)

7.执行下面Python代码后,输出的结果是?()

def swap(a, b): a, b = b, a return a, b

x, y = 1, 2 swap(x, y) print(x, y)

{{ select(7) }}

  • 12
  • 21
  • (2, 1)
  • 报错

8.执行下面Python代码后,输出的结果是?()

def outer(): n = 0 def inner(): nonlocal n n += 1 return n return inner

f = outer() print(f(), f(), f())

{{ select(8) }}

  • 123
  • 111
  • 333
  • 报错

9.以下哪个函数调用会返回[2, 4, 6]?()

def process(1st, func): return [func(x) for x in lst]

nums = [1, 2, 3]

{{ select(9) }}

  • process(nums, lambda x: x % 2)
  • process(nums, lambda x: x + 1)
  • process(nums, lambda x: x ** 2)
  • process(nums, lambda x: x * 2)

10.执行下面Python代码时,哪条调用会报错?( )

def func(a, *, b, c): pass

{{ select(10) }}

  • func(1, b=2, c=3)
  • func(1, 2, c=3)
  • func(a=1, b=2, c=3)
  • func(1, c=3, b=2)

11.一只青蛙要跳上n级台阶。它每次可以跳1阶、2阶或3阶。下列代码可以计算青蛙有多少种不同的跳跃方式可以到达第n阶,其中横线处填写的代码是?( )

def jump_ways(n): if n <= 3: return [0, 1, 2, 4][n] dp = [0] * (n + 1) dp[1], dp[2], dp[3] = 1, 2, 4 for i in range(4, n + 1): dp[i] = ______ return dp[n]

{{ select(11) }}

  • dp[i - 1] * 2
  • dp[i - 3] * 3
  • dp[i - 1] + dp[i - 2]
  • dp[i - 1] + dp[i - 2] + dp[i - 3]

12.下列代码可将24小时制的“HH:MM”时间字符串转换为从午夜(00:00)开始经过的总分钟数(注:此分钟数为正整数),其中横线处填写的代码是?( )

time_str = "8:30" h, m = map(______) # 横线在map的参数部分 total_min = h * 60 + m print(total_min) # 应输出510

{{ select(12) }}

  • int, time_str.split(':')
  • int, time_str.split(':')
  • float, time_str.split(':')
  • str, time_str.split(':')

13.以下代码实现了哪种排序算法?( )

def sort(arr): for i in range(len(arr) - 1): min_idx = i for j in range(i + 1, len(arr)): if arr[j] < arr[min_idx]: min_idx = j arr[i], arr[min_idx] = arr[min_idx], arr[i]

{{ select(13) }}

  • 冒泡排序
  • 插入排序
  • 选择排序
  • 快速排序

14.以下代码的作用是?()

with open("data.txt") as f: while True: line = f.readline() if not line: break print(line, end="")

{{ select(14) }}

  • 读取全部内容后一次性打印
  • 逐行读取并打印,保留原有的换行
  • 跳过空行打印内容
  • 倒序打印文件内容

15.执行下面Python代码后,输出的结果是?()

def test(): try: return "A" finally: return "B"

print(test())

{{ select(15) }}

  • AB
  • A
  • B
  • 报错

判断题

1.C++、Python都是高级编程语言,它们每条语句的执行最终都要通过机器指令来完成。( )

{{ select(16) }}


2.下列程序用于统计字符串中元首字母 (a, e, i, o, u) 的数量。

1 s = "hello world" 2 vowels = "aeiou" 3 count = sum(1 for c in s if c in vowels) 4 print(count)

{{ select(17) }}


3.在函数定义中,**kwargs 必须位于参数列表的最后。( )

{{ select(18) }}


4.执行下面Python代码后,调用函数func可以得到一个列表类型的数据。

1 def func(): 2 return [1, 2], 3 4 5 result = func() 6 print(type(result))

{{ select(19) }}


5.Python代码尝试以读取模式 ("r") 打开不存在的文件会引发 FileNotFoundError 异常。

{{ select(20) }}


6.下面这段程序的时间复杂度为平方阶 ( O(n^2) )。

1 def func(n): 2 for i in range(n): 3 for j in range(n): 4 print(i, j)

{{ select(21) }}


7.对5个不同的数据元素进行直接插入排序,最多需要比较9次。

{{ select(22) }}


8.执行下面Python代码,会触发SyntaxError异常,但不会输出 Error。

1 try: 2 print("Hello" 3 except SyntaxError: 4 print("Error")

{{ select(23) }}


9.Python中允许在同一个 with 语句中打开多个文件。

1 with open('a.txt', 'r') as f1, open('b.txt', 'w') as f2: 2 data = f1.read() 3 f2.write(data)

{{ select(24) }}


10.执行下面Python代码后,会输出 [4, 6]。

1 | print(list(map(sum, zip([1, 2], [3, 4]))))

{{ select(25) }}