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.
What is the output of the program?
❌ 2 3.77 -8 3.77
❌ 2.0000 3 -8 3.77
❌ 2.000 2 -8 3.77
✅ 2.0000 2 -8 3.77
❌ 2.000 2 8 3.77
❌ Error
❌ None of the above
Explanation:
Firstly, integer a is formatted into a float with 4 decimal points, thus 2.0000. After that, a = 2 is formatted into a integer, thus it remains to 2. Index 2 and 1 values are picked next, which are -8 and 3.77 respectively.
❌ 2 3.77 -8 3.77
❌ 2.0000 3 -8 3.77
❌ 2.000 2 -8 3.77
✅ 2.0000 2 -8 3.77
❌ 2.000 2 8 3.77
❌ Error
❌ None of the above
Explanation:
Firstly, integer a is formatted into a float with 4 decimal points, thus 2.0000. After that, a = 2 is formatted into a integer, thus it remains to 2. Index 2 and 1 values are picked next, which are -8 and 3.77 respectively.
What is the output of the code?
❌ 10
❌ 11
❌ 20
✅ 21
❌ 30
❌ 31
❌ Error
❌ None of the above
Explanation:
The continue statement returns the control to the beginning of the loop.
And 'else; clause of for loop is executed when the loop terminates naturally.
❌ 10
❌ 11
❌ 20
✅ 21
❌ 30
❌ 31
❌ Error
❌ None of the above
Explanation:
The continue statement returns the control to the beginning of the loop.
And 'else; clause of for loop is executed when the loop terminates naturally.
What is the output of the code?
❌ Emma 25
❌ name age
❌ {'name': 'Emma', 'age': 25}
❌ ('name', Emma) ('age', 25)
✅ Error
❌ None of the above
Explanation:
Actual result is TypeError: displayPerson() got an unexpected keyword argument 'name'.
To accept variable length of keyword arguments, to create functions that take n number of keyword arguments we use kwargs(prefix a parameter name with a double asterisk ).
This **kwargs collects all passed arguments into a new dictionary, where the argument names are the keys, and their values are the key’s value.
Use *args to get the variable number of positional arguments.
❌ Emma 25
❌ name age
❌ {'name': 'Emma', 'age': 25}
❌ ('name', Emma) ('age', 25)
✅ Error
❌ None of the above
Explanation:
Actual result is TypeError: displayPerson() got an unexpected keyword argument 'name'.
To accept variable length of keyword arguments, to create functions that take n number of keyword arguments we use kwargs(prefix a parameter name with a double asterisk ).
This **kwargs collects all passed arguments into a new dictionary, where the argument names are the keys, and their values are the key’s value.
Use *args to get the variable number of positional arguments.
What is the output of the code?
❌ Nothing is printed
❌ i from A is 0
❌ i from A is 60
✅ i from A is 90
❌ Error
❌ None of the above
Explanation:
Class B is the subclass of class A. During creation of object of class the init function is called. Inside super().init() is used and it invokes the init function of super class A.
Then self.calcI(30) in turn performs the call of class method for which object is created, so calcI from class B is used. It means that 30 is multiplied by 3 and saved to "i". After all, the "i from A is 90" value is printed.
❌ Nothing is printed
❌ i from A is 0
❌ i from A is 60
✅ i from A is 90
❌ Error
❌ None of the above
Explanation:
Class B is the subclass of class A. During creation of object of class the init function is called. Inside super().init() is used and it invokes the init function of super class A.
Then self.calcI(30) in turn performs the call of class method for which object is created, so calcI from class B is used. It means that 30 is multiplied by 3 and saved to "i". After all, the "i from A is 90" value is printed.
What is the output of the code?
❌ Nothing
❌ Inbox Inbox
✅ Inbox Spam
❌ Spam Inbox
❌ Spam Spam
❌ Error
❌ None of the above
Explanation:
The output in this case is again 'Inbox' on one line and 'Spam' on another, because the print statement in the nested function finds the name in the enclosing function’s local scope, and the print at the end finds the variable in the global scope.
❌ Nothing
❌ Inbox Inbox
✅ Inbox Spam
❌ Spam Inbox
❌ Spam Spam
❌ Error
❌ None of the above
Explanation:
The output in this case is again 'Inbox' on one line and 'Spam' on another, because the print statement in the nested function finds the name in the enclosing function’s local scope, and the print at the end finds the variable in the global scope.