Pages

Saturday, 27 July 2019

CBSE Class 11 - Informatics Practices - Python Snippets -1 (Arithmetic Operators) (#cbsenotes)(#eduvictors)

Python Snippets - 1(Arithmetic Operators)

CBSE Class 11 - Informatics Practices - Python Snippets -1 (Arithmetic Operators) (#cbsenotes)(#eduvictors)

Arithmetic operators are used with numeric values to perform mathematical operations. Python supports the following arithmetic operators

+   Addition: To add two numbers i.e. a + b
-   Subtraction: To find difference of two numbers i.e. a - b
*   Multiplication: Product of two numbers e.g. 2 × 3 = 6
/   Division: To find quotient in division i.e. returning the floating-point result of the computation
%   Modulus: To remainder in division method
//  Floor Division or Intger Division i.e. rounds the result down to the nearest whole number
**  Exponentiation e.g. find 12² = 144

The above said are also called binary arithmetic operator because it requires two operands.



Here is the python snippet (using Python 3) showing various arithmetic operations.



# eduvictors solutions
# first program
# Show binary arithmetic operations in python

print("Python program to show binary arithmetic operations");
#addition of two numbers
print("12 + 7 = ", 12 + 7);
#subtraction
print("12 - 7 = ", 12 - 7);
#division
print("12 ÷ 7 = ", 12 / 7);
#multiplication 
print("12 × 7 = ", 12 * 7);
#floor division
print("12 // 7 = ", 12 // 7 );
#remainder
print("12 % 7 = ", 12 % 7);
#exponentiation
print("12⁷ = ", 12 ** 7);


Program Output

CBSE Class 11 - Informatics Practices - Python Snippets -1 (Arithmetic Operators) (#cbsenotes)(#eduvictors)

No comments:

Post a Comment

We love to hear your thoughts about this post!

Note: only a member of this blog may post a comment.