首页 › 试卷 › Python编程考级 › Python编程五级 › 2026年3月青少年软件编程(python五级)等级考试试卷-编程题

2026年3月青少年软件编程(python五级)等级考试试卷-编程题 VIP

Python编程五级 共 3 题 2026 年 含标准答案与解析
返回试卷列表
本页为整卷浏览:先自己做一遍,再展开「查看答案与解析」核对。

一、简答题

1. 简答题

合并有序列表

现有两个列表中的数据已经分别升序排好,要求将两个列表合并到一个新列表中,最终结果依旧升序。例如两个有序列表为a=[11,25,64,75,88]和b=[10,33,46,50,90],最终合并到列表c中,结果为:[10, 11, 25, 33, 46, 50, 64, 75, 88, 90]

实现上述功能的Python程序如下,请在划线处填入合适的代码。

a=[11,25,64,75,88]

b=[10,33,46,50,90]

c=[0]*10

i=0

j=0

k=0

while        ①       :  #当列表a或列表b中的数据未合并完,继续循环

    if i==len(a):    #当列表a中数据已经合并完,只需将列表b中的数据合并

                ②           

        j+=1

    elif j==len(b):  #当列表b中数据已经合并完,只需将列表a中的数据合并

        c[k]=a[i]

        i+=1

    elif        ③     : #当列表a和列表b中的数据都未合并完,将较小值合并到列表c中

        c[k]=a[i]

        i+=1

    else:

        c[k]=b[j]

        j+=1

            ④       #每合并完一个数据,列表c中的指针k往后走一步

print(c)

查看答案与解析
答案:<pre class="brush:python;toolbar:false">a=[11,25,64,75,88] b=[10,33,46,50,90] c=[0]*10 i=0 j=0 k=0 while i&lt;len(a) or j&lt;len(b): #当列表a或列表b中的数据未合并完,继续循环     if i==len(a):      #当列表a中数据已经合并完,只需将列表b中的数据合并         c[k]=b[j]         j+=1     elif j==len(b):    #当列表b中数据已经合并完,只需将列表a中的数据合并         c[k]=a[i]         i+=1     elif a[i]&lt;b[j]:     #当列表a和列表b中数据都未合并完,将较小值合并到列表c中         c[k]=a[i]         i+=1     else:         c[k]=b[j]         j+=1     k+=1      #每合并完一个数据,列表c中的指针k往后走一步 print(c)</pre>
这道题暂未补解析。
2. 简答题

验证邮箱

小明用Python语言写了一个验证邮箱地址和密码是否符合要求的程序。邮箱地址,例如1a2b3c4d56@sina.com,“@”前面的字段叫用户名,“@”后面的字段叫域名。小明的验证程序要求邮箱地址长度不小于15位,同时用户名包含字母和数字。邮箱密码的长度不小于8位,要同时包含大写字母、小写字母以及数字。下面是小明写的程序代码,请你补全横线处的代码,实现前面描述的功能。

# 验证邮箱地址

email = input("请输入邮箱地址: ")

DiZhi = False

if        ①       and '@' in email and '.' in email:

    YongHuMing, YuMing =        ②       

    if YongHuMing and YuMing and '.' in YuMing:

        if any(char.isdigit() for char in YongHuMing) and any(       ③        for char in YongHuMing):

            DiZhi = True

# 验证密码

password = input("请输入密码: ")

MiMa = False

if len(password) >= 8:

    DaXie = any(char.isupper() for char in password)

    XiaoXie = any(char.islower() for char in password)

    ShuZi = any(char.isdigit() for char in password)

    if DaXie and XiaoXie and ShuZi:

        MiMa = True

# 输出结果

if        ④       :

    print("邮箱地址和密码格式均正确。")

else:

    if not DiZhi:

        print("邮箱地址格式不正确。")

    if not MiMa:

        print("密码格式不正确。")

查看答案与解析
答案:<pre class="brush:python;toolbar:false"># 验证邮箱地址 email = input("请输入邮箱地址: ") DiZhi = False #①字符串的长度,邮箱地址长度不小于15位 if len(email) &gt;= 15 and '@' in email and '.' in email:     YongHuMing, YuMing = email.split('@') #②分割字符串,把邮箱地址用“@”分割成用户名和域名     if YongHuMing and YuMing and '.' in YuMing:         #③字符串的常用方法,判断是否含有字母         if any(char.isdigit() for char in YongHuMing) and any(char.isalpha() for char in YongHuMing):             DiZhi = True # 验证密码 password = input("请输入密码: ") MiMa = False if len(password) &gt;= 8:     DaXie = any(char.isupper() for char in password)     XiaoXie = any(char.islower() for char in password)     ShuZi = any(char.isdigit() for char in password)     if DaXie and XiaoXie and ShuZi:         MiMa = True # 输出结果 #④字符串不为空时,逻辑值为True。逻辑运算,两个条件同时满足进入分支语句。 if DiZhi and MiMa:     print("邮箱地址和密码格式均正确。") else:     if not DiZhi:         print("邮箱地址格式不正确。")     if not MiMa:         print("密码格式不正确。")</pre>
这道题暂未补解析。
3. 简答题

统计作品

小明为选出班级中平均分最高的参赛作品,编写Python程序,算法设计如下:

(1)5位评委对3个作品的评分数据存储在列表data中(数据由3位十进制数组成,第1位对应作品号,后2位对应作品得分,如“275”表示2号作品得分75)

(2)统计并输出3个作品的平均分(保留一位小数),选择平均分最高的作品为参赛作品,若最高平均分存在并列,则输出全部并列的最高平均分作品号。程序运行结果如下所示。

-------程序运行结果-------

作品 1 平均分为 78.0

作品 2 平均分为 82.2

作品 3 平均分为 82.2

平均分最高作品号是: [2, 3]

程序如下,请在划线处填入合适的代码:

data=[180,283,385,170,276,384,180,285,380,190,295,390,170,272,372]

s={1:0,2:0,3:0} 

ans=[]

max_zp=0

for c in data:

    zp=       ①       

    fs=c%100

            ②       

for i in range(1,4):

            ③       

    print('作品',i,'平均分为',s[i])

    if s[i]>max_zp:

        max_zp=s[i]

for i in range(1,4):

    if          ④       :

        ans.append(i)

print('平均分最高作品号是:',ans)

查看答案与解析
答案:<pre class="brush:python;toolbar:false">data = [180, 283, 385, 170, 276, 384, 180,285, 380, 190, 295, 390, 170, 272, 372] s = {1: 0, 2: 0, 3: 0} ans = [] max_zp = 0 for c in data:     zp = c//100     fs = c % 100     s[zp] += fs for i in range(1, 4):     s[i] = round(s[i]/5, 1)     print('作品', i, '平均分为', s[i])     if s[i] &gt; max_zp:         max_zp = s[i] for i in range(1, 4):     if s[i] == max_zp:         ans.append(i) print('平均分最高作品号是:', ans)</pre>
这道题暂未补解析。