Monday 16 May 2016

Learn Python the easy way - 2. Simple operations

We can use mathematical operations in Python. Enter a calculation directly into Python console, and it will display the answer.

>>>5 + 2
7

>>>6 * 4
24

>>>4 + 1 - 3
2

Note: There is a space should be there in between the operator. It should work with out operator, but it makes easy to read. (operator -> +, - , / and etc; operand -> values such as 3, 4, 7)

Floats

Floats are used in Python to represent numbers that are not integers. There is a dot would be there in float. Example 3.45, 45.4. When you divide something in Python it will give you an floating value.

>>>3 / 4
0.75

>>>8 / 2
4.0

Exponentiation

We can also manipulate exponentiation in Python. It is the raising of one number to the power of another number.

>>2 ** 3
8

These two asterisks equal to ^ (The power symbol).

Quotient and reminder

To determine the quotient

>>>50 // 3
16

To determine the remainder

>>>10 % 4
2

Example (try to solve your self)

>>>78 % (6 // 4)


4 comments:

  1. Above Information Was Simply Awesome!! and i have heard about the service of ATEES|Wesbite design & development in Thrissur same like this!! kudos...

    ReplyDelete
  2. Very good information. Its very useful for me. We need learn from real time examples and for this we choose good training institute, we need to learn from experts . So we make use of demo classes . Recently we tried Python demo class of Apponix Technologies.
    https://www.apponix.com/Python-Institute/Python-Training-in-Bangalore.html

    ReplyDelete
  3. Very good information. Its very useful for me. We need learn from real time examples and for this we choose good training institute, we need to learn from experts . So we make use of demo classes . Recently we tried Python demo class of Apponix Technologies.
    https://www.apponix.com/Python-Institute/Python-Training-in-Bangalore.html

    ReplyDelete