理论卷2022年12月青少年软件编程(Python) · 六级
YLT Python 6级 2022.12
满分 100 · 及格 60 · 时长 60 分钟 · 共 38 题 (单选25 / 判断10 / 填空3)
试卷阅览 · 免费预览前 10 题 · 交卷后可查看答案与解析
1
单选题号 #20090
分值 2数据文件“abc.txt”中包含若干个英文单词,如图所示:

读取文件"abc.txt"中数据的Python程序段如下:
file = 'abc.txt'
word_b = []
for word in open(file):
if word[0:1] == 'a' and len(word) > 4:
word_b.append(word)
该程序段执行后,列表word_b中的数据为?
2
单选题号 #20091
分值 2下列关于文件的描述错误的是?
3
单选题号 #20092
分值 2with open("readme.txt","r") as f:
r=f.read()
with open("writeme.txt", ① ) as p:
p.write(r)
以上程序实现将readme文件内容追加写入writeme文件中,① 处的模式为?
4
单选题号 #20093
分值 2小林编写一段文件读写操作代码,文件如下图,

代码段如下:
file=open('ceshi.txt','w')
file.write("python is a programming language.")
file.close()
file=open('ceshi.txt','r')
print(file.read())
该代码段运行后,输出的结果为?
5
单选题号 #20094
分值 2下面选项中能创建按钮的是?
6
单选题号 #20095
分值 2使用grid()方法管理布局,需要将Label标签放入第一行第一列,正确写法是?
7
单选题号 #20096
分值 2tkinter中的geometry函数的作用是?
8
单选题号 #20097
分值 2import tkinter as tk
window = tk.Tk()
window.title('Mywindow')
window.geometry('200x100')
var = tk.StringVar()
p= tk.Label(window,textvariable=var,bg='green',font=('Arial', 12),width=15, height=2)
p.pack()
on_hit = False
def hit_me():
global on_hit
if on_hit == False:
on_hit = True
var.set('You hit me!')
else:
on_hit = False
var.set('I Love Python!')
b=tk.Button(window, text='点我', width=15, height=2,command=hit_me)
b.pack()
window.mainloop()
运行如上代码,对按钮点击二次后,在文本框中显示的文字为?
9
单选题号 #20098
分值 2有Python程序段如下,下列选项错误的是?
class Car():
def __init__(self,name,color):
self.name=name
self.color=color
def run(self):
print(self.color +self.name+"is running")
10
单选题号 #20099
分值 2创建了Car类后,用以下代码语句创建了car对象:car=Car()那么需要调用car对象的drive方法,下列选项正确的是?
🔒
已解锁前 10 题
第 11~38 题(共 28 题)注册用户即可作答(每题 1 积分)
本卷为普通试卷:注册用户每题扣 1 积分(每日登录送 30 体验积分),交卷后查看答案与解析
