0

Hello, please what is the use of "int" in the py programs?

18th Sep 2022, 5:54 PM
new Black
new Black - avatar
2 Respostas
+ 1
int is a function which is use to convert string number to integer For example: a = "5" it is a string b = int(a) is is a number When you take user input then it is bydefault string so you need to cast input with int function to get in number: a = input() print (type(a)) # string b = int(a) print (type(b)) #integer
18th Sep 2022, 6:11 PM
A͢J
A͢J - avatar
+ 1
int is a class, which can be called like a function to easily convert numeric strings to integers: int("890") -> 890 int("-7") -> -7 int("4") -> 4 You can also use int to remove decimal parts from floats: int(5.8) -> 5 int(2.99999) -> 2 int(-3.5) -> -3
18th Sep 2022, 8:46 PM
Seb TheS
Seb TheS - avatar