python | data types and transformations


In the code sequence below, I have no problem for "int to float", but I have a problem for "float to int".

Am I missing something? Can you help me to understand?

age         = 28
weight      = 55.6

# int to float

result = float(age)

#float to int
result = int(weight)

I was expecting an integer result, but the decimal value keeps returning.

enter image description here

Asked By: Rıza Çelik



Print the result instead of the weight

#float to int

result = int(weight)
Answered By: Ernest Asare
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.