Converting
Suppose you want to change the type of a certain number. Use the eponymous function to convert a number into a float, int, or complex type. For example, if you convert a float number to an int, the decimal part will simply be removed.
12345# Create a variable with float number float_number = 4.8 # Convert it into integer and output int_number = int(float_number) print(int_number)
Note that converting into an integer is not the same as rounding. The number from the example above, according to math, would be rounded to 5
, but we got 4
.
Perform an integer division of 231
by 17
without using the //
operator.
Дякуємо за ваш відгук!
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Запитайте мені питання про цей предмет
Сумаризуйте цей розділ
Покажіть реальні приклади
Awesome!
Completion rate improved to 4
Converting
Свайпніть щоб показати меню
Suppose you want to change the type of a certain number. Use the eponymous function to convert a number into a float, int, or complex type. For example, if you convert a float number to an int, the decimal part will simply be removed.
12345# Create a variable with float number float_number = 4.8 # Convert it into integer and output int_number = int(float_number) print(int_number)
Note that converting into an integer is not the same as rounding. The number from the example above, according to math, would be rounded to 5
, but we got 4
.
Perform an integer division of 231
by 17
without using the //
operator.
Дякуємо за ваш відгук!