#91. GESP Python 二级 2023年06月 客观题

GESP Python 二级 2023年06月 客观题

2023年GESP 6月 二级

一、单选题(每题2分,共30分)

  1. 高级语言编写的程序需要经过以下( )操作,可以生成在计算机上运行的可执行代码。

{{ select(1) }}

  • 编辑
  • 保存
  • 调试
  • 编译
  1. 能够实现下面流程图功能的伪代码是( )。

{{ select(2) }}

  • if 条件判断 then 语句块
  • if 条件判断 then 什么也不做 else 语句块
  • while 条件判断 do 语句块
  • while not 条件判断 do 语句块
  1. 在Python代码中,变量a的值为4,则表达式5 < a < 20的值是( )。

{{ select(3) }}

  • true
  • false
  • True
  • False
  1. Python表达式round(8/3,3)的值是( )。

{{ select(4) }}

  • 2
  • 3
  • 2.667
  • 2.666
  1. 下面Python代码执行后输出是( )。
import math
print(math.floor(-5.67))

{{ select(5) }}

  • -6
  • -5
  • 0
  • 报错
  1. 下面Python代码执行后的输出是( )。
a, b = 3, 2
if a > b:
    a = b
    b = a
print(a, b, sep=",")

{{ select(6) }}

  • 3,2
  • 2,3
  • 3,3
  • 2,2
  1. 下面Python代码执行后的输出是( )。
m, n = 13, 3
z = 13 % 5
if z < 5:
    print(5)
elif z < 4:
    print(4)
elif z < 3:
    print(3)
else:
    print("0-2")

{{ select(7) }}

  • 5
  • 4
  • 3
  • 0-2
  1. 下面Python代码执行后的输出是( )。
cnt = 0
for i in range(5):
    for j in range(i):
        cnt += 1
print(cnt)

{{ select(8) }}

  • 15
  • 10
  • 5
  • 0
  1. 求m到n之间的间隔数数量,m可能大于n,如3到6之间间隔数数量为2,6和3之间的间隔数同样是2。根据上述题意,在Python代码横线处应填上( )。
# 求m-n之间的间隔数量,如3到6之间间隔数量是2
m = int(input("请输入起点数:"))
n = int(input("请输入终点数:"))
gap = 1
if m > n:
    ________
cnt = 0
for i in range(m + 1, n, gap):
    cnt += 1
print(cnt)

{{ select(9) }}

  • gap = 1
  • gap = 0
  • gap = -1
  • gap = gap
  1. 正整数N除以16的余数为0-15,将0-15对应为不同字符,0-9仍然为0-9,10-15依次对应为大写应为字母A-F。根据上述题意,在Python代码横线处应填上( )。
N = int(input())
Remainder = N % 16  # 保存余数
if N % 16 < 10:
    print(str(Remainder))
else:
    print(________)

{{ select(10) }}

  • chr(ord("A")) + Remainder - 10
  • chr(ord("A") + Remainder)
  • chr(Remainder)
  • chr(ord("A") + Remainder - 10)
  1. 下面Python代码执行后的输出是( )。
cnt = 0
for i in range(10):
    for j in range(i):
        if i % 2:
            break
        cnt += 1
print(cnt)

{{ select(11) }}

  • 55
  • 18
  • 9
  • 33
  1. 有关下面Python代码执行的说法,正确的是( )。
cnt = 0
for i in range(int(input())):
    cnt += 1
print(cnt)

{{ select(12) }}

  • 代码执行后如果输入5,则将输出5
  • 代码执行后如果输入5,则将再输入5次,输出由先后输入值决定
  • 代码输入执行后如果不输入小于0的数,将无限循环
  • 代码执行将报错。
  1. 两个正整数的最大公约数是指能被两个数都整除且最大,如12和18能被2、3和6整除,但6最大,所以12和18的最大公约数是6。两个质数如13和17的最大公约数是1。根据上述题意,在Python代码横线处应填上( )。
m = int(input())
n = int(input())
if m > n:
    m, n = n, m
for i in ___________:
    if m % i == 0 and n % i == 0:
        print(f"最大公约数={i}")
        break

{{ select(13) }}

  • range(m, 0, -1)
  • range(m)
  • range(m, 1, -1)
  • range(1, m)
  1. 产生m和n之间的随机整数,包括n和m。根据上述题意,在Python代码横线处应填上( )。
import random
m = int(input())
n = int(input())
if m > n:
    m, n = n, m
print(________)

{{ select(14) }}

  • m + 1 + int((n - m) * random.random())
  • m + 1 + int((n - m) * random.random)
  • m + 1 + int((n - m)) * random.random
  • m + 1 + (n - m) * int(random.random())
  1. 下面Python代码执行后输出“OK”( )行。
for i in range(8, 2, -2):
    for j in range(i):
        print("ok")

{{ select(15) }}

  • 0
  • 12
  • 18
  • 20

二、判断题(每题2分,共20分)

  1. 诞生于1986年的中华学习机CEC-I入选了2021年的CCF计算机历史记忆(一类),它的内存只有64KB。当时的汉字编码字符集GB2312中共有6763个汉字,假如每个汉字用2个字节编码,将整个GB2312汉字字符集都放入CEC-I的内存,也只占用了不超过1/5的内存空间。( )

{{ select(16) }}

  • 正确
  • 错误
  1. 域名是由一串用点分隔的名字来标识互联网上一个计算机或计算机组的名称,CCF编程能力等级认证官方网站的域名是gesp.ccf.org.cn,其中顶级域名是gesp。( )

{{ select(17) }}

  • 正确
  • 错误
  1. Python表达式5.0 // 2的值为整数2。( )

{{ select(18) }}

  • 正确
  • 错误
  1. 执行Python代码a = f'{101:2.2f}'后,变量a的类型为float,其值101.00。( )

{{ select(19) }}

  • 正确
  • 错误
  1. 当Python执行循环时,如果执行到break语句,这终止其所在循环。( )

{{ select(20) }}

  • 正确
  • 错误
  1. 执行以下Python代码,如果n值为负整数,将输出0。( )
n = int(input())  # 假设输入为负整数、零和正整数
cnt = 0
while n:
    n -= 1
    cnt += 1
print(cnt)

{{ select(21) }}

  • 正确
  • 错误
  1. 执行以下Python代码,将输出π的值。( )
import math
print(math.pi())

{{ select(22) }}

  • 正确
  • 错误
  1. Python是一种低级语言,适合初学者程序设计入门。( )

{{ select(23) }}

  • 正确
  • 错误
  1. {1,1}在Python中是合法的表达式。( )

{{ select(24) }}

  • 正确
  • 错误
  1. 以下Python代码执行时将报错,因为a初始被赋值为整数,随后将其赋值为字符串,故错误。( )
a = 123
a = "ABC"

{{ select(25) }}

  • 正确
  • 错误