万卷网> 电子学会考级 >Python等级考试 > 2022年12月电子学会青少年软件编程(Python三级)等级考试试卷

2022年12月电子学会青少年软件编程(Python三级)等级考试试卷
操作/编程 三级 2022 2023-01-09 12:15:22 63

一、编程题

1.

下面程序实现对二维数据的处理,请你补全代码。

f=open('/data/score2.csv','r')

a=[]

for i in f:

  a.append(i.strip().split(','))

f.close()

     ①     

for i in a:

  s=''

  for j in i:

        ②    

  print(s)


程序执行结果为:

[['王鑫', '86', '90', '92', '99', '94', '95'], ['杨小虹', '93', '97', '95', '90','86', '85'], 

['李静', '89', '98', '99', '94', '90', '85']]


王鑫  86 90 92 99 94 95 

杨小虹 93 97 95 90 86 85 

李静  89 98 99 94 90 85

2.

输入一个正数,以下代码编程求出它的平方根。请你补全代码。

in_var = float(input("请输入一个需要开方的正数,可以使用2位小数:\n x = "))

if in_var < 0:

  x = - in_var

else:

  x = in_var

low = 0.0

high = x

s_root =     ①     

if x > 0 and x < 1:

  high = 1.0

  low = 0

  s_root =     ②     

if x >= 0:

  while abs(     ③     ) > 0.0001:

   if x > 1.0:

      if s_root ** 2 < x:

          low = s_root

      else:

          high = s_root

      s_root =     ④    

    if x == 1.0 and x == 0.0:

      s_root = x

    else:

      if s_root ** 2 < x:

        low = s_root

      else:

        high = s_root

    s_root =     ⑤     

if in_var >= 0:

  print("所求数的平方根为:s_root = %.1f"%(s_root))

3.

在三位数的自然数中,找出至少有一位数字是5的,至少能被3整除的所有整数,并统计个数,具体代码如下:

count=0

lst=[]

for i in range(           ①           ):

    if i%3==0:

        a=i%10

        b=i//10%10

        c=           ②           

        if            ③           :

            count+=1

            lst.append(i)

print("这样的三位数有:",lst)

print("总数量有:",count)

公众号
客服 反馈
顶部