Page 48 - IPP-11
P. 48
30. How can we change the order of evaluation of operator?
Ans. We can use parentheses to alter the order of evaluation of an operator.
31. 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.
32. Which functions are available for creating an array from the numerical ranges in NumPy?
Ans. arange() and linspace().
33. Which function is used to join a sequence of arrays along an existing axis?
Ans. concatenate().
34. 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.
35. Differentiate between division operator (/) and floor division operator (//).
Ans. In Python, the division operator (/) performs integer division on two operands. 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.
For example,
>>> 8//3
2
>>>
the fraction part gets truncated.
36. 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.
37. Name the sequence surrounded by either single quotes or double quotes.
Ans. String
38. How can we convert a string into a number in Python?
Ans. A string which contains a number will be converted into numeric type using int() function.
39. Define a sequence construct.
Ans. A sequence construct constitutes all the statements which are executed sequentially.
40. What is selection construct?
Ans. A selection construct involves execution on the basis of certain test conditions.
41. What is a flow chart?
Ans. A flow chart is a pictorial/graphical representation of a task. Flow charts 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. Give an advantage of using a flow chart.
Ans. Flow chart provides a unique feature of breaking down of a complex problem into parts in order to obtain
the solution to a given problem.
43. 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.
44. What is iteration construct?
Ans. Iteration means repetition of a set of statements until the test condition remains true depending upon
the loop.
3