In this post, I am giving you the Python multiple questions and answers asked by the Media , an Chennai company in Techgig website.
1) The output of 10 // 6 is 1 (// represents floor division and gives integer value of the quotient)
2) The output of below program is
import itertools
L1 = (1,2,3)
L2 = [4,5,6]
Iter = itertools.chain(L1,L2)
print(next(L1))
tuple is not an iterator
3) Use of __slots__ in Python - Special Mechanism to reduce the size of the objects
4) The output of below program is “Bye World”
class test:
def __init__(self):
print("Hello World")
def __init__(self):
print("Bye World")
obj = test()
5) The output of below program is [3,2,1]
L = [[9,8,7],[6,5,4],[3,2,1]]
print(L[2])
6) The output of print(chr(ord('b')+1)) is c
7) The output of below program is [0,1,2,3,4]
def f(x):
for i in range(5):
yield i
g = f(8)
print(list(g))
8) The output of print("{:,}".format(1112223334)) is 1,112,223,334
9) The output of below program is [0,2,4]
a = [x for x in range(5)]
b= [x for x in range(7) if x in a and x % 2 == 0]
print(b)
10) Use of seek() in files - Set file current position at the offset
11) Pandas Dataframe can accept Structured ndarray, Series & DataFrame as inputs
12) Scikit-learn is a library used for Machine learning in Python
13) The output of the below program is ['mango', 'apple', 'orange']
word ='mango,apple,orange'
print(word.split(","))
14) The file that should be present inside the package is __init__.py
15) Function used to close a file in python - close()
16) Slicing in Python - creates slice object representing set of indices specified by range(start,stop,step)
17) Numpy function that returns its argument with a modified shape - reshape
Numpy function that modifies array itself - resize
18) Python supports Automatic Garbage Collection & can be easily integrated with C, C++, COM, ActiveX, COBRA and Java
19) Can we add an element to a = (1,2,3,4,5). No,a is a tuple and cannot insert an element
20) The output of the below program is
import re
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched = re.search(regex, sentence)
print(matched.groupdict())
{'animal': 'horses', 'verb': 'are', 'adjective': 'fast'}
No comments:
Post a Comment