FUNDAMENTALS OF COMPUTER

DATABASE FUNDAMENTALS

DATA WAREHOUSING AND DATA MINING

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What will be the output of the following Python code? x = [’ab’, ‘cd’] for i in x:i.upper()print(x)
A
[‘ab’, ‘cd’]
B
[‘AB’, ‘CD’]
C
[None, None]
D
None of the above
Explanation: 

Detailed explanation-1: -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-2: -Explanation: The line of code can be translated to state that ‘f’ is printed if the argument passed to the Boolean function amount to zero. Else ‘t’ is printed. The argument given to the Boolean function in the above case is ‘spam’, which does not amount to zero. Hence the output is t.

Detailed explanation-3: -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-4: -What will be the output of the following Python functions? Explanation: The function eval is use to evaluate the expression that it takes as an argument. In the above case, the eval() function is used to perform XOR operation between 3 and 2. Hence the output is 1.

There is 1 question to complete.