执行以下代码后,L中的数据为:L = ["life", "answer", 42, 0]for thing in L:if thing == 0:L[thing] = "universe"elif thing == 42:L[1] = "everything"
A. ['life', 'answer', 42, 0]
B. ['universe', 'answer', 42, 0]
C. ['life', 'everything', 42, 0]
D. ['universe', 'everything', 42, 0]
查看答案
执行一下代码后,L3的值为:L1 = ['re']L2 = ['mi']L3 = ['do']L4 = L1 + L2L3.extend(L4)L3.sort()del(L3[0])L3.append(['fa','la'])
A. ['mi', 're', ['fa', 'la']]
B. ['mi', 're', 'fa', 'la']
C. ['re','mi', ['fa', 'la']]
D. ['do','mi', ['fa', 'la']]
执行以下代码后,brunch的值为()。L1 = ["bacon", "eggs"]L2 = ["toast", "jam"]brunch = L1L1.append("juice")brunch.extend(L2)
A. ['bacon', 'eggs', 'toast', 'jam']
B. ['bacon', 'eggs', 'juice', 'toast', 'jam']
C. ['bacon', 'eggs', 'juice', ['toast', 'jam']]
D. ['bacon', 'eggs', ['toast', 'jam']]
有以下类的定义:class Car(object):def __init__(self, w, d):self.wheels = wself.doors = dself.color = ""问下列那句可以实现一个新的Car对象,具有4个轮子,两个门。
A. Car(mycar, 4, 2)
B. mycar = Car(4, 2, "white")
C. mycar = Car(4, 2)
D. mycar = Car(2, 4)
基于以下定义:class Car(object):def __init__(self, w, d):self.wheels = wself.doors = dself.color = ""下列哪个方法改变车的颜色?()
A. def paint(c):color = c
B. def paint(self, c):color = c
C. def paint(c):self.c = c
D. def paint(self, c):self.color = c