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.
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.