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 following?x = 123for i in x:print(i)
A
123
B
1 2 3
C
Error
D
1, 2, 3
Explanation: 

Detailed explanation-1: -As understood from the output given above, the source code results in an error. This is because the data type assigned to x, was that of an integer type. There really is nothing to be looped in an integer type value. Integer values cannot be iterated.

Detailed explanation-2: -Answer: the output is error. As by running this program it occurs error. Hence, the output is error.

Detailed explanation-3: -8. What will be the output of the following Python code snippet? x = ‘abcd’foriinrange(len(x)):i[x]. upper()print(x)a) abcdb) ABCDc) errord) none of the mentionedView AnswerAnswer: cExplanation: Objects of type int aren’t subscriptable.

Detailed explanation-4: -Explanation: The binary form of 1 is 0001. The expression x«2 implies we are performing bitwise left shift on x. This shift yields the value: 0100, which is the binary form of the number 4.

Detailed explanation-5: -Answer: Explanation: The output of the following Python code will be no output, because the while loop will not execute at all. The value of num is “0", which is not in the list lis, so the loop condition will evaluate to False and the loop will not execute.

There is 1 question to complete.