Skip to content

Tag Archives: Output Type

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
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
What is the output of the following program : print 'abcefd'.replace('cd', '12') (A) ab1ef2 (B) abcefd (C) ab1efd (D) ab12ed2 Answer: (B) Explanation: The first… Read More
What is the output of the following program : print 'abef'.partition('cd') (A) (‘abef’) (B) (‘abef’, ‘cd’, ”) (C) (‘abef’, ”, ”) (D) Error Answer: (C)… Read More
What is the output of the following program : print 'cd'.partition('cd') (A) (‘cd’) (B) (”) (C) (‘cd’, ”, ”) (D) (”, ‘cd’, ”) Answer: (D)… Read More
What is the output of the following program : i = 0 while i < 5:     print(i)     i += 1     if i == 3:         break… 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 expression : 3*1**3 (A) 27 (B) 9 (C) 3 (D) 1 Answer: (C) Explanation: Precedence of ** is higher… Read More
What is the output of the following program : def myfunc(a):     a = a + 2         a = a * 2     return a    print… Read More