26.3k views
0 votes
Question #6

Multiple Choice
What type of error occurred with the code below
>>> answer = 'live'
>>> amount = int(answer)
ArithmeticError
o TypeError
ValueError
Floating PointError

2 Answers

6 votes

Answer:

ValueError

Explanation:

Required

Determine the error the program returned

The above will return a ValueError error and the reason is as follows.

The first line of the program initializes variable as 'live'.

The next line tries to convert answer to integer and this is where it returns the error'.

On the second line, variable amount expects that the answer variable to contain number e.g. '567' but because it doesn't contain a complete number (i.e. unexpected values), the program returns a ValueError.

User Nhgrif
by
5.4k points
5 votes

Answer:

ValueError

Step-by-step explanation:

Required

Determine the error the program returned

The above will return a ValueError error and the reason is as follows.

The first line of the program initializes variable as 'live'.

The next line tries to convert answer to integer and this is where it returns the error'.

On the second line, variable amount expects that the answer variable to contain number e.g. '567' but because it doesn't contain a complete number (i.e. unexpected values), the program returns a ValueError.

User Hanne Olsen
by
5.2k points