一个列表名为names,里面有old_driver,rain,jack,shanshan,peiqi,black_girl 元素, 以下用列表分片的方法访问前三个元素的语句正确的是:
A: names[0:3]
B: names[0:2]
C: names[0:4]
D: names[1:4]
A: names[0:3]
B: names[0:2]
C: names[0:4]
D: names[1:4]
举一反三
- 一个列表名为names,里面有old_driver,rain,jack,shanshan,peiqi,black_girl 元素, 以下用列表分片的方法访问前三个元素的语句正确的是: A: names[0:3] B: names[0:2] C: names[0:4] D: names[1:4]
- 已知有一个名为names的空列表,如何向其中添加old_driver,rain,jack,shanshan,peiqi,black_girl 元素? A: names.append("old_driver","rain","jack","shanshan","peiqi","black_girl") B: names.extend("old_driver","rain","jack","shanshan","peiqi","black_girl") C: names.insert("old_driver","rain","jack","shanshan","peiqi","black_girl") D: names.extend(["old_driver","rain","jack","shanshan","peiqi","black_girl"])
- 已知有一个名为names的空列表,如何向其中添加old_driver,rain,jack,shanshan,peiqi,black_girl 元素? A: names.append("old_driver","rain","jack","shanshan","peiqi","black_girl") B: names.extend("old_driver","rain","jack","shanshan","peiqi","black_girl") C: names.insert("old_driver","rain","jack","shanshan","peiqi","black_girl") D: names.extend(["old_driver","rain","jack","shanshan","peiqi","black_girl"])
- 创建一个空列表,命名为names,往里面添加 Lihua、Rain、Jack、Xiuxiu、Peiqi和Black元素。
- names = ["Lihua","Rain","Jack","Xiuxiu","Peiqi","Black"]names.insert(-1,"Peiqi")print(names.index("Peiqi"))