MENU

Chapter 9 Operators in Python Solutions

Question - 11 : -
What is the use of “= =” operator?

Answer - 11 : -

It checks if the value of two operands are equal or not, if yes then condition becomes true.

Question - 12 : -
What is the use of “! =” operator?

Answer - 12 : -

It checks if the value of two operands are equal or not, if values are not equal then condition becomes true.

Question - 13 : -
Why do we use ” < > “operator?

Answer - 13 : -

It checks if the value of two operands are equal or not, if values are not equal then condition becomes true.

Question - 14 : -
What value has been check by ” > = ” operator?

Answer - 14 : -

It checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.

Question - 15 : -
How many types of operations are supported by the Python language ?

Answer - 15 : -

Python language supports the following types of operations.

• Arithmetic operations
• Comparison (i.e. Rotational) operations
• Assignment operations
• Logical operations
• Bitwise operations
• Membership operations
• Identity operations.

Question - 16 : -
What do you mean by Operator precedence?

Answer - 16 : -

Operator precedence determines the grouping of terms in an expression. This affects how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has higher precedence than the addition operator.

Question - 17 : -
Assume if A = 60; and B = 13; then find the values of the following :
A&B
A|B

Answer - 17 : -

Here in binary format they will be as follows:
A = 0011 1100
B = 0000 1101
hence
A&B = 0000 1100 and A|B = 00111101

Question - 18 : -
Explain assigning values to variables in Python.

Answer - 18 : -

Python variables do not have to be explicitly declared to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.

The operand to the left of the = operator is the name of the variable, and the operand to the right of the = operator is the value stored in the variable.
For example:
# !/usr/bin/python
counter = 100 # An integer assignment
miles = 1000.0 # A floating point
name = “John” # A string
print counter
print miles
print name
while running this program, this will produce the following result:
100
1000.0
John

Question - 19 : -
Write the output of the following Python code

a = 6
b = 7
c = 42
print 1, a = = 6
print 2, a = = 7
print 3, a = = 6 and b = = 7
print 4, a = = 7 and b = = 7
print 5, not a = = 7 and b = = 7
print 6,a==7orb==7
print 7, a==7orb==6
print 8, not (a = = 7 and b = = 6)
print 9, not a = = 7 and b = = 6

Answer - 19 : -

1 True
2 False
3 True
4 False
5 True
6 True
7 False
8 True
9 False

Question - 20 : -
 What do you mean by expression “a = 5” ?

Answer - 20 : -

This statement assigns the integer value 5 to the variable a. The part at the left of the assignment operator (=) is known as the 1 value (left value) and the right one as the r value (right value). The l value has to be a variable whereas the l value can be either a constant, a variable, the result of an operation or any combination of these.

Free - Previous Years Question Papers
Any questions? Ask us!
×