Q.1.
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)
Q.2.
What will be the output of the following Python code? names1 = ['Amir', 'Bala', 'Chales'] if 'amir' in names print(1)else: print(2)
Q.3.
What will be the output of the following Python code? names1 = ['Amir', 'Bala', 'Charlie']names2 = [name.lower() for name in namesprint(names2[2][0])
Q.4.
What will be the output of the following Python code? numbers = [numbers.append([5,6,7,8]) print(len(numbers))
Q.5.
To which of the following the “in” operator can be used to check if an item is in it?
Q.6.
What will be the output of the following Python code? list1 = [4]list2 = [print(len(list1 + list2))
Q.7.
What will be the output of the following Python code? def addItem(listParam): listParam += [mylist = [4]addItem(mylist)print(len(mylist))
Q.8.
What will be the output of the following Python code? def example(L): ''' (list) -> list ''' i = result = [] while i < len(L): result.append(L[i]) i = i + return result
Q.9.
What will be the output of the following Python code? veggies = ['carrot', 'broccoli', 'potato', 'asparagus']veggies.insert(veggies.index('broccoli'), 'celery')print(veggies)