Page 27 - ipp11
P. 27
33. Which operator is used to compare the values of operands?
Ans. Relational operator.
34. How can we change the order of evaluation of an operator?
Ans. We can use parentheses to alter the order of evaluation of an operator.
35. What is a unary operator? Give examples.
Ans. The operator which requires only one operand to operate upon is called unary operator. The + and –
operators in Python can be used in both binary and unary forms.
36. Differentiate between binary and ternary operator.
Ans. The operators which require only two operands to work upon are binary operators and those which
require three operands are ternary operators.
37. What are binary operators? Give examples.
Ans. Binary operators are those operators that work with two operands. For example, a common binary
expression would be x+y—the addition operator (+) surrounded by two operands. The binary operators
are further subdivided into arithmetic, relational, logical and assignment operators.
38. Differentiate between division operator (/) and floor division operator (//).
Ans. In Python, the division operator (/) performs integer division on two operands and we get exact division
output. For example,
>>>5/2
2.5
The floor division operator (//) performs an integer division and, as a result, an integer is obtained. It is
also called as Integer Division.
For example,
>>>8//3
2
The fraction part gets truncated.
39. Which function can be used to know the data type of a variable?
Ans. type() method in Python allows us to know the data type of a variable.
40. How can we convert a string into a number in Python?
Ans. A string which contains a number can be converted into numeric type using int() function.
41. What is a flowchart?
Ans. A flowchart is a pictorial/graphical representation of a task. Flowcharts are drawn using certain special-
purpose symbols such as rectangles, diamonds, ovals and circles. These symbols are connected using
arrows termed as flow lines.
42. Define an infinite loop.
Ans. An infinite loop is a loop where a condition never becomes False and keeps on executing. It is a never-
ending loop, such as a while loop in case the situation never resolves to a False value.
43. What is iteration construct?
Ans. Iteration means repetition of a set of statements until the test condition remains True depending upon
the loop.
44. Define the body of the loop.
Ans. The sets of statements which get executed on the test condition becoming True are defined as the body
of the loop.
45. What is the purpose of using a for loop?
Ans. The for loop is used for definite/fixed number of iterations known in advance.
46. What are the supported data types in Python?
Ans. Python has five standard data types—
(i) Numbers—int, float, complex (ii) String
(iii) List (iv) Tuple
(v) Dictionary
V.3