What will be the output of the following Python code?
-
values = [[3, 4, 5, 1 ], [33, 6, 1, 2]]
-
-
for row in values:
-
row.sort()
-
for element in row:
-
print(element, end = " ")
-
print()
Option A. The program prints two rows 3 4 5 1 followed by 33 6 1 2
Option B. The program prints on row 3 4 5 1 33 6 1 2
Option C. The program prints two rows 3 4 5 1 followed by 33 6 1 2
Option D. The program prints two rows 1 3 4 5 followed by 1 2 6 33
True Answer D
Explanation :
Execute in the shell to verify.
What will be the output of the following Python code?
-
values = [[3, 4, 5, 1 ], [33, 6, 1, 2]]
-
-
for row in values:
-
row.sort()
-
for element in row:
-
print(element, end = " ")
-
print()
What will be the output of the following Python code?
nums = set([1,1,2,3,3,3,4,4])
print(len(nums))
Option A. 7
Option B. Error, invalid syntax for formation of set
Option C. 4
Option D. 8
True Answer C
Explanation :
A set doesn’t have duplicate items.
What will be the output of the following Python code?
nums = set([1,1,2,3,3,3,4,4])
print(len(nums))
Which of the following is the correct way to define a two dimensional array?
Option A. int a[ ][4];
Option B. int b[2, 4];
Option C. int c[2][ ];
Option D. int d[ ] [ 4] = {{1, 3, 5, 7}, {2, 4, 6, 8}};
True Answer D
Explanation :
Which of the following is the correct way to define a two dimensional array?
The villagers _____ read and write their mother tongue.
Direction: Fill in the blank with the appropriate modal.
Option A. May
Option B. Can
Option C. Should
Option D. With
True Answer B
Explanation :
The sentence needs a verb which shows the ability to do something. So, the correct verb is "can" as it is used to show the ability of doing something. "May" is incorrect as it is used to show the possibilities. "Should" is also incorrect as it is used to give advise. "With" is not a verb. It is a preposition; so, it is also an incorrect choice.
The villagers _____ read and write their mother tongue.
Direction: Fill in the blank with the appropriate modal.
Firewall is a type of ____________.
Option A. Virus
Option B. Security threat
Option C. Worm
Option D. None of the above
True Answer D
Explanation :
A firewall is a type of cybersecurity tool that is used to filter traffic on a network. Firewalls can be used to separate network nodes from external traffic sources, internal traffic sources, or even specific applications.
Firewall is a type of ____________.
Given digits 2, 2, 3, 3, 3, 4, 4, 4, 4 how many distinct 4 digit numbers greater than 3000 can be formed?
Option A. 50
Option B. 51
Option C. 52
Option D. 54
True Answer B
Explanation :
first place should be occupied by either 3 or 4.
Case 1 : First place is occupied by the digit 4
4 _ _ _
now in the set from where we can pick numbers is left with ={2,2,3,3,3,4,4,4}
if we got 3 of each digit(which are 2,3 and 4) then number of ways by each of those blanks can be
filled in are 3 coz we have 3 choices of digits: pick 2,3 or 4.
But we do not have just enough 2′s to fill all those 3 spaces with the digit 2.
∴ we need to subtract this case where number would be 4222.
So, total numbers obtained using the numbers in our current set =1×3×3×3−1=26.
The first one is for the digit 4, coz its fixed for this case; the subtracted one is for the case 4222 that can't be made possible.
Case 2: First place is occupied by the digit 3
3 _ _ _
now in the set from where we can pick numbers is left with ={2,2,3,3,4,4,4,4}
we have enough 4′s here but lack 3′s and 2′s ∴, the cases we need to subtract are 3222 and 3333
So, total numbers obtained using the numbers in our current set =1×3×3×3−2=25
both cases are independently capable of giving us the answer, we have =26+25=51.
Hence answer is option B.
Given digits 2, 2, 3, 3, 3, 4, 4, 4, 4 how many distinct 4 digit numbers greater than 3000 can be formed?