Ncert solutions for class 11 Computer Science Python Chapter 9 Operators in Python are prepared by CBSE student eCARE expert to score good marks in class 11. Classes 11 Computer Science Python Chapter 9 Operators in Python contain many topics which are very important to score good in class 11. There are some important topic mentioned below:
Following example to understand all the arithmetic operators available in Python programming language:
a = 21
b = 10
c = 0
c = a + b
print “Line 1 – Value of c is “, c
c = a -b
print “Line 2 – Value of c is “, c
c = a * b
print “Line 3 – Value of c is “, c
c = a/b
print “Line 4 – Value of c is “, c
c = a % b
print “Line 5 – Value of c is “, c
a = 2
b = 3
c = a**b
print “Line 6 – Value of c is “, c
a = 10
b = 5
c = a//b
print “Line 7 – Value of c is “, c
When you execute the above program it produces following result:
Line 1 – Value of c is 31
Line 2 – Value of c is 11
Line 3 – Value of c is 210
Line 4 – Value of c is 2
Line 5 – Value of c is 1
Line 6 – Value of c is 8
Line 7 – Value of c is 2
What do you mean by Operator precedence?
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.
Assume if A = 60; and B = 13; then find the values of the following :
Here in binary format they will be as follows:
A = 0011 1100
B = 0000 1101
A&B = 0000 1100 and A|B = 00111101
Assume if A = 60; and B = 13, then find the values of the following.
A ∧ Band ~A
Here in binary format they will be as follows :
A = 00111100 B = 0000 1101
A ∧ B = 0011 0001 and ~A = 1100 0011
Explain assigning values to variables in Python.
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.
counter = 100 # An integer assignment
miles = 1000.0 # A floating point
name = “John” # A string
while running this program, this will produce the following result:
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 7, a==7orb==6
print 8, not (a = = 7 and b = = 6)
print 9, not a = = 7 and b = = 6
What do you mean by expression “a = 5” ?
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.
What do you mean by statement in Python?
A statement is an instruction that the Python interpreter can execute. We have seen two kinds of statements: print and assignment.
When you type a statement on the command line, Python executes it and displays the result, if there is one. The result of a print statement is a value. Assignment statements don’t produce a result.
What do you mean by expression in Python ?
An expression is a combination of values, variables, and operators. If you type an expression on the command line, the interpreter evaluates it and displays the result:
Explain Operators and Operands?
Operators are special symbols that represent computations like addition and multiplication. The values the operator uses are called Operands.