BaşlayınÜcretsiz Başlayın

Division with integers and floats

Python supports two different division operators: / and //. In Python 3, / will consistently return a float result, and // is floor division and will consistently return an integer result. Floor division is the same as doing math.floor(numerator/divisor), which returns the highest integer less than or equal to the result of the division operation. You can learn more about math.floor in the Python Docs.

Bu egzersiz

Data Types in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Print the result of 2/1 and 1/2.
  • Print the floored division result of 2//1 and 1//2.
  • Print the type of 2/1 and 2//1.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Print the result of 2/1 and 1/2
print(____)
print(____)

# Print the floored division result of 2//1 and 1//2
print(____)
print(____)

# Print the type of 2/1 and 2//1
print(____)
print(____)
Kodu Düzenle ve Çalıştır