+ 1

how i can change type of float to the integer in this code,,,,,,,, x = 9 y = 3 print (x/y)

12th Jun 2023, 10:43 AM
Amirhossein
Amirhossein - avatar
4 Respostas
+ 2
Use the built-in function: int() x = 9 y = 3 print(int(x/y)) This thing is called 'Type Casting'. By using the int() function, you changed the float data type to an integer.
12th Jun 2023, 11:57 AM
I-M-J
I-M-J - avatar
+ 1
You can use int or use floor division(//) Example: print(5//2) gives output 2
12th Jun 2023, 1:02 PM
Bishnu Chalise
Bishnu Chalise - avatar
+ 1
x = 9 y = 3 result = int(x / y) #result = float(x / y) print(result)
13th Jun 2023, 6:44 PM
Vaibhav
Vaibhav - avatar