MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the output of the code shown below?l1=[1, 2, 3]l2=[4, 5, 6][x*y for x in l1 for y in l2]
A
a) [4, 8, 12, 5, 10, 15, 6, 12, 18]
B
[18, 12, 6, 15, 10, 5, 12, 8, 4]
C
[4, 5, 6, 8, 10, 12, 12, 15, 18]
D
[4, 10, 18]
Explanation: 

Detailed explanation-1: -1. What will be the output of the following Python code? Explanation: In the code shown above, each of the numbers of the list, that is, 1, 2, 3, 4 and 5 are AND-ed with 1 and the result is printed in the form of a list. Hence the output is [1, 0, 1, 0, 1].

Detailed explanation-2: -What is the output of print 0.1 + 0.2 == 0.3? a) True b) False c) Machine dependent d) Error View Answer Answer: b Explanation: Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary.

Detailed explanation-3: -Explanation: [5, 9, 0, 8] will be the output of below Python code.

Detailed explanation-4: -What will be the output of the following Python code? Explanation: The function s1|s2 as well as the function s1. union(s2) returns a union of the two sets s1 and s2. Hence the output of both of these functions is: 1, 2, 3, 4, 5, 6, 8.

There is 1 question to complete.