Question: 21 -
Study the following function: What will be the output of this function?all([2,4,0,6])
-
False
-
Invalid code
-
True
-
0
Answer:
False
Solution:
If any element is zero, it returns a false value, and if all elements are non-zero, it returns a true value. Hence, the output of this "all([2,4,0,6])" function will be false.
If any element is zero, it returns a false value, and if all elements are non-zero, it returns a true value. Hence, the output of this "all([2,4,0,6])" function will be false.
Question: 22 -
Study the following code: What will be the output of this program?x = ['XX', 'YY']
for i in a:
i.lower()
print(a)
-
[XX, yy]
-
['xx', 'yy']
-
['XX', 'YY']
-
None of these
Answer:
['XX', 'YY']
Solution not available.
Question: 23 -
Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:\java.txt''?
-
Infile = open.file(''d:\\java.txt'',''r'')
-
Infile = open(''d:\\java.txt'', ''r'')
-
Infile = open(''d:\java.txt'',''r'')
-
Infile = open(file=''d:\\\java.txt'', ''r'')
Answer:
Infile = open(''d:\\java.txt'', ''r'')
Solution not available.
Question: 24 -
Study the following function: What will be the output of this code?import math abs(math.sqrt(36))
-
6.0
-
-6
-
Error
-
6
Answer:
6.0
Solution not available.
Question: 25 -
Study the following program: What will be the output of this code?x = 1
while True:
if x % 5 = = 0:
break
print(x)
x + = 1
-
0 3 1
-
None of these
-
2 1
-
error
Answer:
error
Solution:
Syntax error, there should not be a space between + and =.
Syntax error, there should not be a space between + and =.