Skip to content

Tag Archives: Python-Quizzes

Which of the following function convert a string to a float in python? (A) int(x [,base]) (B) long(x [,base] ) (C) float(x) (D) str(x) Answer:… Read More
What is the output of the following code? Consider Python 2.7. print tuple[1:3] if tuple == ( 'abcd', 786 , 2.23, 'john', 70.2 ) else… Read More
Which of the following is correct about Python? (A) It supports automatic garbage collection. (B) It can be easily integrated with C, C++, COM, ActiveX,… Read More
time.time() returns ________ (A) the current time (B) the current time in milliseconds (C) the current time in milliseconds since midnight (D) the current time… Read More
To start Python from the command prompt, use the command ______ (A) execute python (B) go python (C) python (D) run python Answer: (C) Explanation:… Read More
What will be displayed by the following code? def f(value, values):     v = 1     values[0] = 44 t = 3 v = [1, 2, 3] f(t, v) print(t, v[0]) (A) 1 1 (B) 1 44 (C) 3… Read More
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)? (A) [3, 4, 5, 20, 5, 25, 1, 3]… Read More
________ is a simple but incomplete version of a function. (A) Stub (B) Function (C) A function developed using bottom-up approach (D) A function developed… Read More
Given a string s = “Welcome”, which of the following code is incorrect? (A) print s[0] (B) print s.lower() (C) s[1] = ‘r’ (D) print… Read More
What is the output of the following program : i = 0 while i < 3:      print i      i += 1 else:      print 0 (A)… Read More
What is the output of the following program : print '{0:-2%}'.format(1.0 / 3) (A) 0.33 (B) 0.33% (C) 33.33% (D) 33% Answer: (C) Explanation: The… Read More
What is the output of the following program : print '{0:.2}'.format(1.0 / 3) (A) 0.333333 (B) 0.33 (C) 0.333333:-2 (D) Error Answer: (B) Explanation: .2… Read More
What is the output of the following program : print "Hello World"[::-1] (A) dlroW olleH (B) Hello Worl (C) d (D) Error Answer: (A) Explanation:… Read More
What is the output of the following program : import re sentence = 'horses are fast' regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)') matched = re.search(regex, sentence)… Read More
What is the output of the following segment : chr(ord('A')) (A) A (B) B (C) a (D) Error Answer: (A) Explanation: ord() function converts a… Read More