2022年3月电子学会青少年软件编程(Python二级)等级考试试卷
操作/编程
二级
2022
2022-12-11 15:01:25
111次
一、单选题
想得到的输出为"My name is Kevin and I am 10 years old."以下选项正确的是?( )
| A. print('My name is %s and I am %d years old.',%('Kevin',10)) |
B. print('My name is %s and I am %d years old.'%('Kevin',10)) |
| C. print('My name is %c and I am %d years old.'%('Kevin',10)) |
D. print('My name is %s and I am %d years old.'%',Kevin',%10)) |
【知识点】 电子学会Python二级
关于以下代码段的说法错误的是?( )
a = [1, 2, 5, 4, 3]
a.sort(reverse=True)
print(a)
| A. a.sort(reverse=True)语句中的reverse默认值为False。 |
B. 省略a.sort(reverse=True)语句中的reverse=True,代码运行结果不变。 |
| C. 将以上代码的a.sort(reverse=True)改为a=sorted(a,reverse=True),代码运行结果和原题的结果一样。 |
D. 以上代码运行结果为:[5, 4, 3, 2, 1]。 |
【知识点】 电子学会Python二级
