Computer Science, asked by rubisrivastva, 6 months ago

what is the difference between '/' and '//' operator in python??

Answers

Answered by malabarik1968
17

Answer:

Difference between the ‘// ‘ and ‘/‘ in Python.

Normal Division : Divides the value on the left by the one on the right. Notice that division results in a floating-point value.

divide=10/3 #Normal Division  

print(divide)  

OUTPUT :  3.333333333333333  

Floor Division : Divides and returns the integer value of the quotient. It neglects the digits after the decimal.

divide=10//3 #Floor Division  

print(divide)  

OUTPUT :  3

Explanation:

Answered by arshikhan8123
9

Answer:

'/' is the division operator.

'//' is the floor division operator.

Explanation:

Python supports different types of operators:

They are arithmetic operators, logical operators, assignment operators, etc.

'/' and '//' belong to the arithmetic operators.

'/' is used for the normal division of two numbers.

'//' is used to obtain the smallest integer nearest to the quotient obtained by dividing two numbers.

Let us see an example to understand this.

x = 15

y = 3

print(x / y)   #This prints output as 5

print(x // y)  #This prints output as 5

a = 19

b = 4

print(a // b)  #This prints output as 4

print(a / b)  #This prints output as 4.75

So, if the quotient obtained by dividing two numbers is not an integer, then operators '/' and '//' will return different answers.

'/' is the division operator. '//' is the floor division operator.

#SPJ2

Similar questions