Answer : D
Explain : Any list, tuple, set, and dictionary are True, except empty ones- False. bool(0) is False and other bool value are true always.
Solve 25 % 5 ?
0
1
5
None
Answer : A
Explain : % - modulus gives remainder. So we got 0 remainder.
Which one of the following has the same precedence level ?
Division, Power, Multiplication, Addition and Subtraction
Division and Multiplication
Subtraction and Division
Power and Division
Answer : B
Explain : Multiplication and Division are at the same precedence level. Similarly, “Addition and Subtraction” are at the same precedence level.
Which operator has highest precedence ?
()
/
**
%
Answer : A
Explain : Parentheses have highest precendence in python. Use PEMDAS to remeber precedence P- parenthese, E- exponent, M- multiplation, D- division, A- Addition, S-subtraction.
what will be the output of following pseudocode, where ^ repersent XOR operator ?
integer a, b, c
set b=4, a=3
c=a^b
print c
0
1
7
5
Answer: C
Explain : In this b=4 = 0110 and a=3=0011. Now solve with XOR it give = 0111 = 7.
Operators with the same precedence are evaluated from ?
Left to right
right to left
Anywhere
None of these
Answer : A
Explain : Same precedence operator are evaluated from left to right .
What is the output of this expression, 4*1**6?
4096
1296
0
4
Answer : D
Explain : As we known first exponent solve then power. 1**6 = 1 then 4*1 = 4.
What is the return value of trunc() ?
float
complex
integer
string
Answer : C
Explain : trunc() return integer value. It just remove the no. which is after the decimal.
Which of following is Identity operator ?
is, is not
in , not in
and, or , not
None of above
Answer : A
Explain : Identity operator in python are : is and is not. In, not in is membership operator.
Solve ((5.00/5)+4.00/4) what we get when executed in python ?
2
2.00
2.0
2.000
Answer :C
Explain : When we solve this we get 2.0 . To remove decimal we use int() function.
Which of the following operators has right-to-left associativity in Python ?
%
//
**
*
Answer : C
Explain : Exponent operator(**) has right-to-left associativity in Python.
Which of the following is the truncation division operator ?
/
//
%
*
Answer : B
Explain : // ( flow division )is the operator for truncation division. It is called so because it returns only the integer part. For example: 22//3 = 1.
What will be the output of following statement ?
a=0
b=3
while a+b<8:
a+=1
print(a, end="")
0 1 2 3 4
1 2 3 4 5 6
1 2 3 4 5
None of the above
Answer : C
Explain : First while condition check 0+3<8, true then a value change to a=1 and print (a) when the value reach to a=5 then print (a) but after that 5+3<8 condition false. Then while stop.
What is the output of following code ?
x=2
if x<5:
print(x)
else:
pass
2 3 4
1 2 3 4
2
5
Answer : C
Explain : It checks x<5 which is true 2<5, then print (x) = 2.
What is output of int(2.39) ?
2
2.39
2.00
2.4
Answer : A
Explain : int() function gives only integer value. So it gives only 2.
Which of the following is right shift operator ?
>>
<<
|
~
Answer : A
Explain : Right shift operator denote as >>.
What is the output of following ?
i=2
while True:
if i%3==0:
break
print(i ,end="")
i+=2
2 4 6 8 10.....
2 4
2 3
error
Answer : B
Explain : First time i value is 2, i%3 ( 2%3 = 2) then i value print but when i value is 6 ( 6%3 ==0) which is true then break condition active and break the loop.