GPYC Exam QuestionsBrowse all questions from this exam

GPYC Exam - Question 14


What is the output of the following command typed in Python interactive mode?

>>> print(`and` in `And now for something completely different`)

Show Answer
Correct Answer: AC

The command uses backticks (`) around the string instead of single or double quotes, which causes a syntax error in Python. The correct syntax should involve using either single (' ') or double (' ') quotes for string literals.

Discussion

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

When I run this code: print('and' in `And now for something completely different`) I get a syntax error: print('and' in `And now for something completely different`) ^ SyntaxError: invalid syntax

ootesttakeroo
Feb 23, 2023

can someone explain?

GJBBOption: C
Apr 8, 2024

The code has the wrong quotes on examtopics, if you type: print('and' in 'And now for something completely different') it returns false