GPYC Exam QuestionsBrowse all questions from this exam

GPYC Exam - Question 12


Review the following Python 3 code.

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

Show Answer
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

3 comments
Sign in to comment
AZIrvThoOption: A
Sep 29, 2023

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

VenudharOption: A
Nov 18, 2023

The option is A

cmk428Option: A
May 13, 2024

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.