In previous blog see saw how to get the product of two numbers in python.

In today's blog we will see how to divide of two numbers in python.

In python the normal division / returns the float value as output by in floor division // it returns the integer value.

First lets see how to use normal division method.

Sample input :-

     8 3

Sample output :-

     2.6666666666666665

Algorithm :-

  1. Start.
  2. Get the input of two numbers num1 and num2 in integer format.
  3. print the quotient of two numbers.
  4. Stop.

Now lets see this in code with explanation.

Program :-

     num1 = int(input())

     num2 = int(input())

     print(num1 / num2)

Explanation :-

  1. num1 is a variable which stores the given number which we give in integer format because by default the input() reads the input as string so we use int() to convert that value to integer.
  2. Similarly, num2 is also a variable which stores the second number in integer format.
  3. print() is a function to print the output by dividing the two numbers.
Output :-
  1. Program screenshot

  2. Output screenshot

Now lets see how the use floor division method.

Sample input :-

     8 3

Sample output :-

     2

Algorithm :-

  1. Start.
  2. Get the input of two numbers num1 and num2 in integer format.
  3. print the quotient of two numbers.
  4. Stop.

Now lets see this in code with explanation.

Program :-

     num1 = int(input())

     num2 = int(input())

     print(num1 // num2)

Explanation :-

  1. num1 is a variable which stores the given number which we give in integer format because by default the input() reads the input as string so we use int() to convert that value to integer.
  2. Similarly, num2 is also a variable which stores the second number in integer format.
  3. print() is a function to print the output by dividing the two numbers.
Output :-
  1. Program screenshot


  2. Output screenshot


In next blog we will see how get the remainder of two numbers in python.