Question: 26 -
Study the following statements: What will be the output of this statement?>>> print(ord('h') - ord('z'))
-
17
-
18
-
-17
-
-18
Answer:
-18
Solution:
ASCII value of h is less than the z. Hence the output of this code is 104-122, which is equal to -18.
ASCII value of h is less than the z. Hence the output of this code is 104-122, which is equal to -18.
Question: 27 -
Study the following program: Which of the following is the correct output of this program?class book: def __init__(a, b): a.o1 = b class child(book): def __init__(a, b): a.o2 = b obj = page(32) print "%d %d" % (obj.o1, obj.o2)
-
32 32
-
Error
-
32 None
-
32
Answer:
Error
Solution:
Error is generated because self.o1 was never created.
Error is generated because self.o1 was never created.
Question: 28 -
Study the following statement: What will be the output of this statement?>>>"a"+"bc"
-
abc
-
a
-
a bc
-
a+bc
Answer:
abc
Solution:
In Python, the "+" operator acts as a concatenation operator between two strings.
In Python, the "+" operator acts as a concatenation operator between two strings.
Question: 29 -
Study the following code: What will be the output of this code?>>>"masterquiz"[5:]
-
master
-
quiz
-
None of these
-
masterquiz
Answer:
quiz
Solution:
Slice operation is performed on the string.
Slice operation is performed on the string.
Question: 30 -
Study the following function: What will be the output of this code?any([5>8, 6>3, 3>1])
-
Ture
-
None of these
-
Invalid code
-
False
Answer:
Ture