What is the output of the code?
❌ [1, 2, 3, 1, 2, 3] and [1, 2, 3, 1, 2, 3]
✅ [1, 2, 3] and [1, 2, 3, 1, 2, 3]
❌ [1, 2, 3, 1, 2, 3] and [1, 2, 3]
❌ [1, 2, 3] and [1, 2, 3]
❌ Error
❌ None of the above
Explanation:
The statement listA = listA * 2 inside the funcA creates a new list instead of modifying the original one.
Whereas the list extend() method modifies the original list.
❌ [1, 2, 3, 1, 2, 3] and [1, 2, 3, 1, 2, 3]
✅ [1, 2, 3] and [1, 2, 3, 1, 2, 3]
❌ [1, 2, 3, 1, 2, 3] and [1, 2, 3]
❌ [1, 2, 3] and [1, 2, 3]
❌ Error
❌ None of the above
Explanation:
The statement listA = listA * 2 inside the funcA creates a new list instead of modifying the original one.
Whereas the list extend() method modifies the original list.
What is the output of the code?
❌ 'Finally Block!'
❌ 'Index out of bound!'
❌ 'Done!' followed by 'Nothing is wrong!'
❌ 'Nothing is wrong!' followed by 'Finally block!'
✅ 'Done!' followed by 'Nothing is wrong!' followed by 'Finally block'
❌ 'Index out of bound!' followed by 'Finally block'
❌ Error
❌ None of the above
Explanation:
In the above Try block we make a list of total 10 elements by adding 5 times zero and 5 times 10. Thus when we try to find out the element at index 9 no error is raised by Python.
Accordingly, firstly the 'Done!' will be printed. Then 'Nothing is wrong!' will be printed because no excpetion was raised. And then 'Finally block' is printed because finally block is executed in any case.
❌ 'Finally Block!'
❌ 'Index out of bound!'
❌ 'Done!' followed by 'Nothing is wrong!'
❌ 'Nothing is wrong!' followed by 'Finally block!'
✅ 'Done!' followed by 'Nothing is wrong!' followed by 'Finally block'
❌ 'Index out of bound!' followed by 'Finally block'
❌ Error
❌ None of the above
Explanation:
In the above Try block we make a list of total 10 elements by adding 5 times zero and 5 times 10. Thus when we try to find out the element at index 9 no error is raised by Python.
Accordingly, firstly the 'Done!' will be printed. Then 'Nothing is wrong!' will be printed because no excpetion was raised. And then 'Finally block' is printed because finally block is executed in any case.
What is the output of the code?
❌ 500 100
❌ 500 -100
❌ 200 0
❌ 200 100
✅ Error
❌ None of the above
Explanation:
Actual result is SyntaxError. We can mix positional arguments with keyword arguments. But we must keep in mind that keyword arguments must follow positional arguments.
Having a positional argument after keyword arguments will result in error.
❌ 500 100
❌ 500 -100
❌ 200 0
❌ 200 100
✅ Error
❌ None of the above
Explanation:
Actual result is SyntaxError. We can mix positional arguments with keyword arguments. But we must keep in mind that keyword arguments must follow positional arguments.
Having a positional argument after keyword arguments will result in error.
What is the output of the code?
❌ true
❌ false
❌ true false
❌ Error will occur in line 1
✅ Error will occur in line 3
❌ Error will occur in line 4
❌ None of the above
Explanation:
Break statement can only be used with loop or switch. So, using break with if statement causes SyntaxError: 'break' outside loop.
❌ true
❌ false
❌ true false
❌ Error will occur in line 1
✅ Error will occur in line 3
❌ Error will occur in line 4
❌ None of the above
Explanation:
Break statement can only be used with loop or switch. So, using break with if statement causes SyntaxError: 'break' outside loop.
What is the output of the code?
❌ 0 1 2
❌ a b c
❌ 0a 1b 2c
✅ Error
❌ None of the mentioned
Explanation:
TypeError will occur, cannot unpack non-iterable int object because objects of type int aren’t iterable.
❌ 0 1 2
❌ a b c
❌ 0a 1b 2c
✅ Error
❌ None of the mentioned
Explanation:
TypeError will occur, cannot unpack non-iterable int object because objects of type int aren’t iterable.
What is the output of the program?
❌ 2 3 -4 3
✅ 2 3 -3 3.12
❌ 2 4 -3 3
❌ 2 3 -4 3.12
❌ Error
❌ None of the above
Explanation:
int() returns the integer value of a number, int(2.13) = 2. floor() returns the largest integer lesser or equal to the number, floor(3.777) = 3. ceil() returns smallest integer greater or equal to the number, ceil(-3.12) = -3. fabs() return the modulus of the number, thus fabs(-3.12) = 3.12.
❌ 2 3 -4 3
✅ 2 3 -3 3.12
❌ 2 4 -3 3
❌ 2 3 -4 3.12
❌ Error
❌ None of the above
Explanation:
int() returns the integer value of a number, int(2.13) = 2. floor() returns the largest integer lesser or equal to the number, floor(3.777) = 3. ceil() returns smallest integer greater or equal to the number, ceil(-3.12) = -3. fabs() return the modulus of the number, thus fabs(-3.12) = 3.12.
What is the output of the program?
❌ ['11', '4', '1886', '11']
❌ ['1141886'] ['1', '1']
❌ ['11', '4', '1886'] ['11']
✅ ['11', '4', '1886'] ['1', '1']
❌ Error
❌ None of the above
Explanation:
\d is equivalent to [0-9] and \d+ will match a group on [0-9], group of one or greater size. In first statement, group of digits are 11, 4, 1886. In the second statement, \d will treat each each digit as different entity, thus 1, 1.
❌ ['11', '4', '1886', '11']
❌ ['1141886'] ['1', '1']
❌ ['11', '4', '1886'] ['11']
✅ ['11', '4', '1886'] ['1', '1']
❌ Error
❌ None of the above
Explanation:
\d is equivalent to [0-9] and \d+ will match a group on [0-9], group of one or greater size. In first statement, group of digits are 11, 4, 1886. In the second statement, \d will treat each each digit as different entity, thus 1, 1.