186k views
2 votes
What will be the output of the following lines of code and the user’s response?

>>> answer = input("What does your dog weigh? ")
What do you weigh? 85.7
>>> weight = int(answer)
>>> print("The weight is" , weight)
An error occurs.
The weight is 85.7
The weight is 85
The weight is 86

1 Answer

2 votes

Answer:

An error occurs.

Step-by-step explanation:

You cannot pass a string representation of a float ("85.7") into an int conversion, you'd have to convert it into a float first.

So weight = int(float(answer)) would work.

User Pelotasplus
by
7.1k points