What will be the output of the following Python code?
print('abcdef'.partition('cd'))
print('abcdefcdgh'.partition('cd'))
print('abcd'.partition('cd'))
What will be the output of the following Python code snippet?
print('cd'.partition('cd'))
print('abef'.partition('cd'))
print('abcdef12'.replace('cd', '12'))
print('abef'.replace('cd', '12'))
print('abcefd'.replace('cd', '12'))
print('xyyxyyxyxyxxy'.replace('xy', '12', 100))
print('abcdefcdghcd'.split('cd'))
print('abcdefcdghcd'.split('cd', 0))
print('abcdefcdghcd'.split('cd', -1))
print('abcdefcdghcd'.split('cd', 2))
print('Ab!2'.swapcase())
print('ab cd ef'.title())
print('ab cd-ef'.title())
What is the output of the following code?
list1=[2, 33, 222, 14, 25] print(list1[ : -1 ])
names = ['Amir', 'Bear', 'Charlton', 'Daman'] print(names[-1][-1])
list1 = [11, 2, 23] list2 = [11, 2, 2] print(list1 < list2)
print("Welcome to Python".split())
mylist=list("a#b#c#d".split('#')) print(mylist)
myList = [1, 5, 5, 5, 5, 1] max = myList[0] indexOfMax = 0 for i in range(1, len(myList)): if myList[i] > max: max = myList[i] indexOfMax = i print(indexOfMax)
myList = [1, 2, 3, 4, 5, 6] for i in range(1, 6): myList[i - 1] = myList[i] for i in range(0, 6): print(myList[i], end = " ")
list1 = [1, 3] list2 = list1 list1[0] = 4 print(list2)
def f(values): values[0] = 44 v = [1, 2, 3] f(v) print(v)
values = [[3, 4, 5, 1], [33, 6, 1, 2]] v = values[0][0] for row in range(0, len(values)): for column in range(0, len(values[row])): if v < values[row][column]: v = values[row][column] print(v)
values = [[3, 4, 5, 1], [33, 6, 1, 2]] v = values[0][0] for lst in values: for element in lst: if v > element: v = element print(v)
values = [[3, 4, 5, 1 ], [33, 6, 1, 2]] for row in values: row.sort() for element in row: print(element, end = " ") print()
matrix = [[1, 2, 3, 4], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]] for i in range(0, 4): print(matrix[i][1], end = " ")
def m(list): v = list[0] for e in list: if v < e: v = e return v values = [[3, 4, 5, 1], [33, 6, 1, 2]] for row in values: print(m(row), end = " ")
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] def ttt(m): v = m[0][0] for row in m: for element in row: if v < element: v = element return v print(ttt(data[0]))
points = [[1, 2], [3, 1.5], [0.5, 0.5]] points.sort() print(points)
a=[10,23,56,[78]] b=list(a) a[3][0]=95 a[1]=34 print(b)
a=[1,2,3] b=a.append(4) print(a) print(b)
a=[13,56,17] a.append([87]) a.extend([45,67]) print(a)
word1="Apple" word2="Apple" list1=[1,2,3] list2=[1,2,3] print(word1 is word2) print(list1 is list2)
places = ['Bangalore', 'Mumbai', 'Delhi'] places1 = places places2 = places[:] places1[1]="Pune" places2[2]="Hyderabad" print(places)
a= [1, 2, 3, 4, 5] for i in range(1, 5): a[i-1] = a[i] for i in range(0, 5): print(a[i],end = " ")
a=["Apple","Ball","Cobra"] a.sort(key=len) print(a)
print([i.lower() for i in "HELLO"])
t=32.00 for x in t: print(x)
a=[(2,4),(1,2),(3,9)] a.sort() print(a)
>>> a={5,6,7} >>> sum(a,5)
a={5,6,7,8} b={7,8,9,10} print(len(a+b))
What will the output of following code?
a={1,2,3} b={1,2,3,4} c=a.issuperset(b) print(c)
d = {"john":40, "peter":45} print("john" in d)
d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} print(d1 == d2)
d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} print(d1 > d2)
d = {"john":40, "peter":45} print(d["john"])
d = {"john":40, "peter":45} print(list(d.keys()))
a={1:"A",2:"B",3:"C"} for i,j in a.items(): print(i,j,end=" ")
a={1:"A",2:"B",3:"C"} print(a.get(1,4))