2024年9月电子学会青少年软件编程(Python四级)等级考试试卷
客观题
四级
2024
2024-11-14 17:34:22
59次
2024年9月电子学会青少年软件编程(Python四级)等级考试试卷
客观题
四级
2024
2024-11-14 17:34:22
59次
一、单选题
4.
小陈编写了一段计算超市打折活动的程序,运行时报错,原因可能是下面哪项?( )
def discount(price,rate):
final_price = price * rate
old_price = float ( input ('请输入原价:'))
rate = float (input ('请输入折扣率:'))
discount ( old_price , rate )
print ('打折后价格是:',final_price ) | A. 调用函数时参数传递错误,应该以参数名price传递 |
B. final_price是局部变量,只在函数体内生效 |
| C. 定义函数时,没有定义参数的类型 |
D. 函数体没有return语句,函数执行完毕后返回结果为None |
【知识点】 电子学会Python四级
25.
小明设计了一个计算矩形体积的函数,以下调用函数的四个选项中,参数传递错误的是?( )
def vol(length,width,height): v = length * width * height return v
| A. s = vol(3,4,7) print(s) |
B. s = vol(3, 7,width=4) print(s) |
| C. s = vol(3,height=7,width=4) print(s) |
D. s = vol(3, width=4,height=7) print(s) |
【知识点】 电子学会Python四级
