What is the output of the program?
❌ 2 4
❌ 0 0
✅ 1 2 1 2
❌ -1 -2 -1 -2
❌ Error will occur
❌ None of the mentioned
Explanation:
"a * 2" means, string prints 2 times. "a * 0" means, string is empty.
Any string cannot be negative. Therefore, the string in the 3rd case will not print any word.
❌ 2 4
❌ 0 0
✅ 1 2 1 2
❌ -1 -2 -1 -2
❌ Error will occur
❌ None of the mentioned
Explanation:
"a * 2" means, string prints 2 times. "a * 0" means, string is empty.
Any string cannot be negative. Therefore, the string in the 3rd case will not print any word.
What is the result of the code?
❌ 300 400
✅ 100 400
❌ 100 200
❌ 300 200
❌ None of the above
❌ Error
Explanation:
In the above code x is a private variable declared in the class P. Thus value of x cannot be changed in the class C which inherits class P. But y is not a private variable thus its value can be changed.
❌ 300 400
✅ 100 400
❌ 100 200
❌ 300 200
❌ None of the above
❌ Error
Explanation:
In the above code x is a private variable declared in the class P. Thus value of x cannot be changed in the class C which inherits class P. But y is not a private variable thus its value can be changed.
What is the output of the code?
❌ 1 2 3
❌ 1 3 2
❌ 1 (3, 2)
❌ 1 (2, 3)
✅ 1 {'c': 3, 'b': 2}
❌ 1 {'c': 2, 'b': 3}
❌ Error
❌ None of the above
Explanation:
The code prints '1 {'c': 3, 'b': 2}', because 1 is passed to a by name and the **kargs collects the remaining keyword arguments into a dictionary. We could step through the extra keyword arguments dictionary by key with any iteration tool (e.g., for key in kargs: ...)
❌ 1 2 3
❌ 1 3 2
❌ 1 (3, 2)
❌ 1 (2, 3)
✅ 1 {'c': 3, 'b': 2}
❌ 1 {'c': 2, 'b': 3}
❌ Error
❌ None of the above
Explanation:
The code prints '1 {'c': 3, 'b': 2}', because 1 is passed to a by name and the **kargs collects the remaining keyword arguments into a dictionary. We could step through the extra keyword arguments dictionary by key with any iteration tool (e.g., for key in kargs: ...)
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.