What will be the output of the following Python code? veggies = ['carrot', 'broccoli', 'potato', 'asparagus'] veggies.insert(veggies.index('broccoli'), 'celery')
View Question
What will be the output of the following Python code?
def example(L):
”’ (list) -> list
”’
i = 0
result = []
while i < len(L):
result.append(L[i])
i = i + 3
return result
What will be the output of the following Python code? def example(L): ''' (list) ...
View Question
What will be the output of the following Python code?
def increment_items(L, increment):
i = 0
while i < len(L):
L[i] = L[i] + increment
i = i + 1
values = [1, 2, 3]
print(increment_items(values, 2))
print(values)?
What will be the output of the following Python code? def increment_items(L, increment): i ...
View Question
What will be the output of the following Python code?
def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))
What will be the output of the following Python code? def addItem(listParam): listParam += ...
View Question
What will be the output of the following Python code?
list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]
print(len(list1 + list2))
What will be the output of the following Python code? list1 = [1, 2, 3, 4] list2 = ...
View QuestionTo which of the following the “in” operator can be used to check if an item is in it?
a) Lists b) Dictionary c) Set d) ...
View Question
What will be the output of the following Python code?
numbers = [1, 2, 3, 4]
numbers.append([5,6,7,8])
print(len(numbers))
What will be the output of the following Python code? numbers = [1, 2, 3, 4] numbers.append([5,6,7,8])
View Question
What will be the output of the following Python code?
names1 = [‘Amir’, ‘Bala’, ‘Charlie’]
names2 = [name.lower() for name in names1]
print(names2[2][0])
What will be the output of the following Python code? names1 = ['Amir', 'Bala', 'Charlie'] names2 = [name.lower() ...
View Question
What will be the output of the following Python code?
names1 = [‘Amir’, ‘Bala’, ‘Chales’]
if ‘amir’ in names1:
print(1)
else:
print(2)
What will be the output of the following Python code? names1 = ['Amir', 'Bala', 'Chales'] if 'amir' ...
View Question
What will be the output of the following Python code?
def f(i, values = []):
values.append(i)
return values
f(1)
f(2)
v = f(3)
print(v)
What will be the output of the following Python code? def f(i, values = []): ...
View Question