python | data types and transformations

Question:

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)
print(result)

#float to int
result = int(weight)
print(weight)

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

enter image description here

Asked By: Rıza Çelik

||

Answers:

Print the result instead of the weight

#float to int

result = int(weight)
print(result)
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.