Python Programming Language Quiz 1

Python Programming Language Quiz 1

Can you perform mathematical operation on String?



What is the output of the following? sentence = 'lions are fast' regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)') matched = re.search(regex, sentence) print(matched.groupdict())





Xrange returns





Which command is used to retrieve the character at third index from the string s=”Hello”?





How will you reverse a list?





What is the output of the following? numbers = {} numbers[(1,2,4)] = 8 numbers[(4,2,1)] = 10 numbers[(1,2)] = 12 sum = 0 for k in numbers: sum += numbers[k] print len(numbers) + sum





What is pickling





Can multiple exceptions be handled in one block of except statements ?





What is the output of the following? def foo(j, y=[]): y.append(y.append(j)) return y for j in range(3): x = foo(j) print(x)





Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?







Search

Shortcodes Ultimate

 
Follow Us
 
BGP