What will be the output of the Python code?
❌ 0 1 2
❌ 0 1 2 0 1 2 0 1 2 …
✅ None None None
❌ None of the mentioned
Explanation:
Variable x takes the values 0, 1 and 2. set.add() returns None which is printed.
❌ 0 1 2
❌ 0 1 2 0 1 2 0 1 2 …
✅ None None None
❌ None of the mentioned
Explanation:
Variable x takes the values 0, 1 and 2. set.add() returns None which is printed.
What will be the output of the Python code?
❌ 6
❌ 12
✅ 24
❌ Error
❌ None of the mentioned
Explanation:
In the above program r and s are lambda functions or anonymous functions and q is the argument to both of the functions. In first step we have initialized x to 2. In second step we have passed x as argument to the lambda function r, this will return x*2 which is stored in x. That is, x = 4 now. Similarly in third step we have passed x to lambda function s, So x = 4*3. i.e, x = 12 now. Again in the last step, x is multiplied by 2 by passing it to function r. Therefore, x = 24.
❌ 6
❌ 12
✅ 24
❌ Error
❌ None of the mentioned
Explanation:
In the above program r and s are lambda functions or anonymous functions and q is the argument to both of the functions. In first step we have initialized x to 2. In second step we have passed x as argument to the lambda function r, this will return x*2 which is stored in x. That is, x = 4 now. Similarly in third step we have passed x to lambda function s, So x = 4*3. i.e, x = 12 now. Again in the last step, x is multiplied by 2 by passing it to function r. Therefore, x = 24.
What will the Python code return?
❌ 70251
❌ 7
❌ 15
✅ Error
❌ None of the mentioned
Explanation:
list1 contains integers as its elements. Hence these cannot be concatenated to string str1 by simple "+" operand. These should be converted to string first by use of str() function,then only these will get concatenated.
❌ 70251
❌ 7
❌ 15
✅ Error
❌ None of the mentioned
Explanation:
list1 contains integers as its elements. Hence these cannot be concatenated to string str1 by simple "+" operand. These should be converted to string first by use of str() function,then only these will get concatenated.
Which statement is correct?
❌ id(a1) and id(a2) will have same value
✅ id(a1) and id(a2) will have different values
❌ Two objects with same value of attribute cannot be created
❌ None of the above
Explanation:
Although both a1 and a2 have same value of attributes,but these two point to two different object. Hence, their id will be different.
❌ id(a1) and id(a2) will have same value
✅ id(a1) and id(a2) will have different values
❌ Two objects with same value of attribute cannot be created
❌ None of the above
Explanation:
Although both a1 and a2 have same value of attributes,but these two point to two different object. Hence, their id will be different.
What will be the output of the code?
❌ 113
❌ 14
❌ 12
✅ Error
❌ None of the mentioned
Explanation:
As you can see the variable ‘b’ is of type integer and the variable ‘a’ is of type string. Also as Python is a strongly typed language we cannot simply concatenate an integer with a string. We have to first convert the integer variable to the type string to concatenate it with a string variable. So, trying to concatenate an integer variable to a string variable, an exception of type “TypeError” is occurred.
❌ 113
❌ 14
❌ 12
✅ Error
❌ None of the mentioned
Explanation:
As you can see the variable ‘b’ is of type integer and the variable ‘a’ is of type string. Also as Python is a strongly typed language we cannot simply concatenate an integer with a string. We have to first convert the integer variable to the type string to concatenate it with a string variable. So, trying to concatenate an integer variable to a string variable, an exception of type “TypeError” is occurred.
What will be output for the code?
❌ A. Error, the syntax of the invoking method is wrong
❌ B. The program runs fine but nothing is printed
❌ C. 1 0
✅ D. 1 2
Explanation:
In the above piece of code, the invoking method has been properly implemented and hence x=1 and y=2.
❌ A. Error, the syntax of the invoking method is wrong
❌ B. The program runs fine but nothing is printed
❌ C. 1 0
✅ D. 1 2
Explanation:
In the above piece of code, the invoking method has been properly implemented and hence x=1 and y=2.
What will be output for the code?
❌ 1
❌ 2
✅ 3
❌ 4
❌ Code does not compile
❌ Error will occur
Explanation:
In Python the precedence order is first NOT then AND and in last OR. So the if condition and second elif condition evaluates to False while third elif condition is evaluated to be True resulting in 3 as output.
❌ 1
❌ 2
✅ 3
❌ 4
❌ Code does not compile
❌ Error will occur
Explanation:
In Python the precedence order is first NOT then AND and in last OR. So the if condition and second elif condition evaluates to False while third elif condition is evaluated to be True resulting in 3 as output.