Chapter 7 More on Python
Brain Developer
A. Fill in the blanks:
1. The order in which the operators are evaluated is called Precedence of operators.
2. The valid combination of both operands and operators makes an expression, which returns a computed result.
3. '+' operator is used to concatenate or join two or more strings.
4. In Python, the flow of execution is altered by the use of Control Statements.
5. The if else control structure is used when either of the two different actions is to be performed depending upon the result of the conditional expression.
6. In Python, the conditional statement is terminated with a colon symbol.
B. State True or False:
1. An operator does not need any operand to perform any operations. (False)
Correct Answer: An operator need one or more operand to perform any operations.
2. Unary operators can be used on more than three operators. (False)
Correct Answer: Unary operators can be used on only one operand.
3. Exponential operator is used to calculate the power of numbers. (True)
4. Higher precedence operators are operated before the lower precedence operators. (True)
5. 'if-elif-else' statements are used when we have to evaluate only one condition. (False)
Correct Answer: 'if-elif-else' statements are used when we have to evaluate multiple condition.
6. Iterative Statements enable the execution of a set of statements to repeat till the condition is true. (True)
C. Application Based Questions:
1. Sumit is converting a decimal number to a binary number. He needs to calculate the remainder in each step. Which operator do you suggest him to use for this task?
Answer: He should use % (Remainder) Operator for this task.
2. Arif’s father is a businessman. He wants to determine whether he made a profit or loss based on the revenue figures. Suggest an appropriate conditional construct he can use to solve the problem.
Answer: He should use if…else conditional statement construct to solve the problem.
D. Multiple Choice Questions:
1. The values on which operators work are known as ___________________.
a) Operands
b) Operating system
c) Data
d) Numbers
Answer: a) Operands
2. // (floor division) is same as / (division).
a) True
b) False
c) In some cases, yes
d) None of these
Answer: c) In some cases, yes
3. In which construct the statements in a program are executed in a sequential manner followed by one after the another with no possibility of branching off to another action.
a) Conditional
b) Sequential
c) Iterative
d) None of these
Answer: b) Sequential
4. Which statement among the following enables the execution of a statement to repeat till the condition is true.
a) Conditional
b) Sequential
c) Iterative
d) None of these
Answer: c) Iterative
5. If in a conditional expression, the condition evaluates to false, then which block of statements will be executed first?
a) else
b) if
c) both
d) None of these
Answer: a) else
E. Name the following:
1. Two types of arithmetic operators __________________
2. Three types of Logical operators ____________________
3. Two operators used in strings __________________
4. The statement which is used to evaluate only one condition ________________
5. The procedure to write the steps of a program in a well defined way ________________
Answer:
1. Two types of arithmetic operators: Unary operator, Binary operator
2. Three types of Logic operators: and, or, not
3. Two operators used in strings: '+' and '*'
4. The statement which is used to evaluate only one condition: if statement
5. The procedure to write the steps of a program in a well defined way: Algorithm
F. Answer the following questions briefly:
1. What do you mean by the term operator?
Answer: Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result.
2. What is the difference between '/' and '//' operator?
Answer: '/' and '//' both are Binary Arithmetic Operators. '/' (Division) operator is used to divide the numbers and give an output in the decimal form, e.g., value of 5/2 is 2.5 whereas '//' (Floor division) divides the numbers and gives an output in the integer form, e.g., value of 5//2 is 2 and the value of -5/2 is -3.
3. What is the use of '*' operator in a string manipulation?
Answer: '*' operator in a string manipulation is used to replicate a given string for a number of times. It is also known as Replication Operator.
4. What are the different types of control structures?
Answer: The different types of control structures are Sequential statements, Conditional statements, and Iterative statements.
5. Explain the use of if…else control structure.
Answer: The if…else control structure is used when either of the two different actions is to be performed depending upon the result of the conditional expression.
No comments:
Post a Comment