Exam GPYC All QuestionsBrowse all questions from this exam
Question 12

Review the following Python 3 code.

Which input would generate the response `Thank You` in the output of this program?

    Correct Answer: A

    The code will print 'Thank you' only if a valid integer is entered. The input '539' is a valid integer, which means the 'int(n)' statement will succeed, and the program will proceed to break out of the loop and print 'Thank you'. The other options ('4a6e', '(52-4)', and 'three') are not valid integers and will raise a ValueError, leading to the message 'Not an integer' being printed instead.

Discussion
cmk428Option: A

The code returns Thank you if you submit an int. If you fuzz it with string it will return the exception. I ran it both ways in VS Code.

VenudharOption: A

The option is A

AZIrvThoOption: A

None of the options return "Thank you" - only 539 returns an answer: "539"