1.写出print()输出值
a = [1, 2, 3, 4, 5]
# [1, 3, 5]
print(a[::2])
# [4, 5]
print(a[-2:])
2.写出调用函数的输出结果
def fn(x, lst=[]):
for i in range(x):
lst.append(i * i)
print(lst)
# [0, 1]
fn(2)
# [3, 2, 1, 0, 1, 4]
fn(3, [3,2,1])
# [0, 1, 0, 1, 4]
fn(3)
3.写出print()输出值文章来源:https://www.toymoban.com/news/detail-614549.html
class Person:
name = []
p1 = Person()
p2 = Person()
p1.name.append('Andy')
print(p1.name) # ['Andy']
print(p2.name) # # ['Andy']
print(Person.name) # # ['Andy']
4.写出print()输出值文章来源地址https://www.toymoban.com/news/detail-614549.html
def extendList(val, lst=[]):
lst.append(val)
re
到了这里,关于Python代码实现题型的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!