/ is a division operator, whereas // is a floor division operator. Python division (/) operator return the result of division in floating point number, whereas floor division operator (//) return the result of division as integer.
For example, 3/2 = 1.5 and 3//2 = 1.
division_vs_floor_division.py
a=3 b=2 msg1 = f'{a}/{b} = {a/b}' msg2 = f'{a}//{b} = {a//b}' print(msg1) print(msg2)
Output
3/2 = 1.5 3//2 = 1
No comments:
Post a Comment