Tag: Comprehension
-
Python Questions and Answers – List Comprehension – 2
Python Multiple Choice Questions & Answers (MCQs) focuses on “List Comprehension – 2”. Q 1. Read the information given below carefully and write a list comprehension such that the output is: [‘e’, ‘o’] w=”hello” v=(‘a’, ‘e’, ‘i’, ‘o’, ‘u’) A. [x for w in v if x in v]B. [x for x in v if…
-
Python Questions and Answers – List Comprehension – 1
Python Multiple Choice Questions & Answers (MCQs) focuses on “List Comprehension – 1”. Q 1. What will be the output of the following Python code? l=[1,2,3,4,5] [x&1 for x in l] A. [1, 1, 1, 1, 1]B. [1, 0, 1, 0, 1]C. [1, 0, 0, 0, 0]D. [0, 1, 0, 1, 0] Show Answer Answer:-B.…
-
Python Questions and Answers – Matrix List Comprehension
Python Multiple Choice Questions & Answers (MCQs) focuses on “Matrix List Comprehension”. Q 1. Which of the following matrices will throw an error in Python?A. A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] B. B = [[3, 3, 3] [4, 4, 4] [5, 5, 5]] C. C = [(1, 2, 4), (5,…