#G4209. [GESP202506 四级] 客观题

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

[GESP202506 四级] 客观题

单选题

1.2025年4月19日在北京举行了一场颇为瞩目的人形机器人半程马拉松赛。比赛期间,跑动着的机器人会利用身上安装的多个传感器所反馈的数据来调整姿态、保持平衡等,那么这类传感器类似于计算机的( )。

{{ select(1) }}

  • 处理器
  • 存储器
  • 输入设备
  • 输出设备

2.小杨购置的计算机使用一年后觉得内存不够用了,想购置一个容量更大的内存条,这时需要的内存条是( )。

{{ select(2) }}

  • RAM
  • ROM
  • CACHE
  • EPROM

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

s1 = {('a', 1), ('b', 2)}
s2 = {('b', 2), ('a', 1)}
t1 = {('a', 1), ('b', 2)}
t2 = {('b', 2), ('a', 1)}
print(s1 == s2, t1 == t2)

{{ select(3) }}

  • True False
  • False False
  • True True
  • False True

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

def func(*args): return sum(args) / len(args)

result = func(1, 2, 3, 4, 5) print(result)

{{ select(4) }}

  • 15
  • 3
  • 3.0
  • 报错

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

def func(a, b, *, c, d=0): pass

{{ select(5) }}

  • func(1, 2, 3, 4)
  • func(a=1, 2, c=3)
  • func(1, 2, 3, d=4)
  • Yfunc(1, 2, c=3)

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

x = 10

def func(): x += 1 return x

print(func())

{{ select(6) }}

  • A. 10
  • B. 11
  • C. 报错
  • D. None

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

func = lambda x: x * 2 if x > 0 else x // 2 print(func(-4), func(4))

{{ select(7) }}

  • A. 2-8
  • B. -2 8
  • C. -8 2
  • D. 报错

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

def apply(func, x): return func(x) def square(n): return n * n result = apply(square, 4) print(result)

{{ select(8) }}

  • A. 16
  • B. 8
  • C. 4
  • D. 报错

9.执行下面Python代码后,会发生什么?()

try: raise ValueError except Exception: print("A") except ValueError: print("B")

{{ select(9) }}

  • 打印"A"
  • 打印"B"
  • 同时打印"A"和"B"
  • 报错

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

try: 1 / 0 except ValueError: print("A") else: print("B") print("C")

{{ select(10) }}

  • A C
  • B C
  • C
  • 报错

11.以下哪个选项可以正确读取文件“data.txt”的全部内容并返回一个字符串?

with open("data.txt", "r") as f: content = ______

{{ select(11) }}

  • f.readlines()
  • f.readline()
  • f.read()
  • f.read(100)

12.以下哪种文件打开模式可以在不截断文件的情况下同时支持读写?()

{{ select(12) }}

  • A. "x"
  • B. "r+"
  • C. "a"
  • D. "x"

13.以下哪种排序算法的时间复杂度在最坏情况下是 (O(n^2))?()

{{ select(13) }}

  • 冒泡排序
  • 选择排序
  • 插入排序
  • 以上都是

14.执行以下代码后,输出的结果是?()

data = ['apple', 'Banana', 'cherry'] print(sorted(data))

{{ select(14) }}

  • ['apple', 'Banana', 'cherry']
  • ['Banana', 'apple', 'cherry']
  • ['apple', 'cherry', 'Banana']
  • ['cherry', 'Banana', 'apple']

15.给定一个整数数组 nums,计算其最长递增子序列的长度。子序列可以不连续,但必须保持原数组的顺序。例如:nums = [10, 9, 2, 5, 3, 7, 101, 18] 的最长递增子序列是 [2, 3, 7, 101],长度为4。

def length_of_LIS(nums): dp = [1] * len(nums) # dp[i] 表示以 nums[i] 结尾的最长递增子序列长度 for i in range(1, len(nums)): for j in range(1): if nums[j] < nums[i]: dp[i] = ______ # 填空 return max(dp)

{{ select(15) }}

  • dp[j] + 1
  • dp[i] + 1
  • min(dp[i], dp[j] + 1)
  • max(dp[i], dp[j] + 1)

判断题

1.现在,人们参加各种闭卷考试时通常都不允许将智能手机、平板电脑等带入考场,因为智能手表通常都有嵌入操作系统及通信等功能,所以也不允许携带入考场。( )

{{ select(16) }}


2.执行下面Python代码后,输出的结果为3。

data = {'ids': [1, 2], 'name': 'test'} data['ids'].extend(['g', 'e', 's', 'p']) print(len(data['ids']))

{{ select(17) }}


3.执行下面Python代码会报错,因为lambda函数不能有默认参数。

f = lambda x, y=2: x + y f(1)

{{ select(18) }}


4.执行下面Python代码后,输出的结果为[1, 4, 9]。

print(list(map(lambda x: x**2, [1, 2, 3])))

{{ select(19) }}


5.执行下面Python代码后,将只输出try。

def test(): try: return "try" finally: print("finally执行了") print(test())

{{ select(20) }}


6.在Python中,readlines()方法返回的文件内容包含行末尾的换行符(\n)。

{{ select(21) }}


7.选择算法的核心思想是利用已知条件逐步推导后续结果。

{{ select(22) }}


8.选择排序是一种稳定的排序算法。

{{ select(23) }}


9.以下代码的时间复杂度是0(n)。

def func(n): for i in range(n): for j in range(n): print(i, j)

{{ select(24) }}


10.以下代码的空间复杂度是0(1)。

def sum_elements(arr): total = 0 for num in arr: total += num return total

{{ select(25) }}