[3, 4, 5, 20, 5, 25, 1]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
What will be the output of the following Python code?
print("Welcome to Python".split())
[“Welcome”, “to”, “Python”]
(“Welcome”, “to”, “Python”)
{“Welcome”, “to”, “Python”}
“Welcome”, “to”, “Python”
mylist=list("a#b#c#d".split('#')) print(mylist)
[‘a’, ‘b’, ‘c’, ‘d’]
[‘a b c d’]
[‘a#b#c#d’]
[‘abcd’]
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)
1
2
3
4
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 = " ")
2 3 4 5 6 1
6 1 2 3 4 5
2 3 4 5 6 6
1 1 2 3 4 5
list1 = [1, 3] list2 = list1 list1[0] = 4 print(list2)
[1, 3]
[4, 3]
[1, 4]
[1, 3, 4]
def f(values): values[0] = 44 v = [1, 2, 3] f(v) print(v)
[1, 44]
[1, 2, 3, 44]
[44, 2, 3]
[1, 2, 3]
Heeeo
Heelo
Heleo
None
s[]
s.getitem(3)
s.__getitem__(3)
s.getItem(3)
s.__len__()
len(s)
size(s)
s.size()
i.__add(j)
i.__add__(j)
i.__Add(j)
i.__ADD(j)
input(“Enter a string”)
eval(input(“Enter a string”))
enter(“Enter a string”)
eval(enter(“Enter a string”))
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)
5
6
33
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()
The program prints two rows 3 4 5 1 followed by 33 6 1 2
The program prints on row 3 4 5 1 33 6 1 2
The program prints two rows 1 3 4 5 followed by 1 2 6 33
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 = " ")
1 2 3 4
4 5 6 7
1 3 8 12
2 5 9 13
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 = " ")
3 33
1 1
5 6
5 33
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)
[[1, 2], [3, 1.5], [0.5, 0.5]]
[[3, 1.5], [1, 2], [0.5, 0.5]]
[[0.5, 0.5], [1, 2], [3, 1.5]]
[[0.5, 0.5], [3, 1.5], [1, 2]]
a=[10,23,56,[78]] b=list(a) a[3][0]=95 a[1]=34 print(b)
[10,34,56,[95]]
[10,23,56,[78]]
[10,23,56,[95]]
[10,34,56,[78]]