Integers, Floats and Operations – Dealing with numbers in python

Hello techies!!!

Hope you all are having a great day, let’s make it better by learning something new.

Today, we will talk about numbers.

What are number?

We have 1,2,3,4,… and so on called as positive numbers or natural numbers.

If we add zero to above series, its called whole numbers.

If we have numbers like -1, -2, -3, … and so on , these are called negative numbers.

If we combine above series then we have … -3, -2, -1, 0, 1, 2, 3 and all these number together are called as integers.

Numbers with fraction part are considered floating point numbers or floats. For example : 2.342, 1.324, 2.3, 3.1415

In programming, we have 6 types of basic arithmetic operations :

  1.  Addition : Represented by ‘+’ sign
    5+2 = 7
  2. Subtraction : Represented by ‘-‘ sign
    5-2 = 3
  3. Multiplication : Represented by ‘*’ sign
    5*2 = 10
  4. Division : Represented by ‘/’ sign
    5/2 = 2.5
  5. Modulo : Represented by ‘%’ sign
    5%2 = 1
    This basically helps us to get remainder value. When 5 is divided by 2 it leaves 1 as remainder and 2 as quotient
  6. Power : Represented by ‘**’ sign
    5**3 = 5*5*5 = 125
    This means 5 to the power of 3.

Sixth point is special, that works with python but not with other languages. Other operations can be used in other languages as well.

We can practice doing this and use python for arithmetic and as a calculator.

  1. Start python by just typing python in Command prompt or power shell.
    python successfully start
  2. Type in all the examples shown above, in python shell and see python do calculation for you.
    operations example

That’s it for this tutorial.

See you guys, in the next tutorial.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.