What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('xyy', 2, 11))
print("xyyzxyzxzxyy".count('xyy', -10, -1))
print("xyyzxyzxzxyy".endswith("xyy"))
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
print("ab\tcd\tef".expandtabs())
print("ab\tcd\tef".expandtabs(4))
print("ab\tcd\tef".expandtabs('+'))
print("abcdef".find("cd") == "cd" in "abcdef")
print("abcdef".find("cd"))
print("ccdcddcd".find("c"))
print("Hello {0} and {1}".format('foo', 'bin'))
print("Hello {1} and {0}".format('bin', 'foo'))
print("Hello {} and {}".format('foo', 'bin'))
print("Hello {name1} and {name2}".format(name1='foo', name2='bin'))
print("Hello {0!r} and {0!s}".format('foo', 'bin'))
print("Hello {0} and {1}".format(('foo', 'bin')))
print('ab12'.isalnum())
print('ab,12'.isalnum())
print('ab'.isalpha())
print('a B'.isalpha())
What will be the output of the following Python code snippet?
print('0xa'.isdigit())
print(''.isdigit())
print('my_string'.isidentifier())
print('__foo__'.isidentifier())
print('for'.isidentifier())
print('abc'.islower())
print('a@ 1,'.islower())
print('11'.isnumeric())
print('1.1'.isnumeric())
print('1@ a'.isprintable())
print(''''''.isspace())
print('\t'.isspace())
print('HelloWorld'.istitle())
print('Hello World'.istitle())
print('Hello!2@#World'.istitle())
print('1Rn@'.lower())
print('xyyzxxyxyy'.lstrip('xyy'))
print('xyxxyyzxxy'.lstrip('xyy'))
print('cba'.maketrans('abc', '123'))
print('a'.maketrans('ABC', '123'))
print('abcdef'.partition('cd'))
print('abcdefcdgh'.partition('cd'))
print('abcd'.partition('cd'))
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\ncd\nef'.splitlines())
print('Ab!2'.swapcase())
print('ab cd ef'.title())
print('ab cd-ef'.title())
print('abcd'.translate('a'.maketrans('abc', 'bcd')))
print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))
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)
>>>"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()