Home / Programming Questions / Page 5

Prgramming MCQs Feed | Page - 5

```Q. What is the output of the following code? def foo(fname, val): print(fname(val)) foo(max, [1, 2, 3]) foo(min, [1, 2, 3])```

(A) 3 1
(B) 1 3
(C) error
(D) none of the mentioned

```Q. What is the output of the following? elements = [0, 1, 2] def incr(x): return x+1 print(list(map(elements, incr)))```

(A) [1, 2, 3].
(B) [0, 1, 2].
(C) error
(D) none of the mentioned

```Q. What is the output of the following? elements = [0, 1, 2] def incr(x): return x+1 print(list(map(incr, elements)))```

(A) [1, 2, 3].
(B) [0, 1, 2].
(C) error
(D) none of the mentioned

```Q. What is the output of the following? def to_upper(k): return k.upper() x = ['ab', 'cd'] print(list(map(to_upper, x)))```

(A) [„AB‟, „CD‟].
(B) [„ab‟, „cd‟].
(C) none of the mentioned
(D) error

```Q. What is the output of the following? x = ['ab', 'cd'] print(len(list(map(list, x))))```

(A) 2
(B) 4
(C) error
(D) none of the mentioned

```Q. What is the output of the following piece of code? #mod1 def change(a): b=[x*2 for x in a] print(b) #mod2 def change(a): b=[x*x for x in a] print(b) from mod1 import change from mod2 import change #main s=[1,2,3] change(s)```

(A) [2,4,6].
(B) [1,4,9].
(C) [2,4,6].
(D) There is a name clash

(A) August
(B) Aug
(C) 08
(D) 8

`Q. Which of the following formatting options can be used in order to add „n‟ blank spaces after a given string „S‟?`

(A) print(“-ns”%S)
(B) print(“-ns”%S)
(C) print(“%ns”%S)
(D) print(“%-ns”%S)

Download our easy to use, user friendly Android App from Play Store. And learn MCQs with one click.