GPYC Exam QuestionsBrowse all questions from this exam

GPYC Exam - Question 20


What is the output when the following commands are typed in Python interactive mode?

Show Answer
Correct Answer: C

When running the given commands in Python interactive mode, the output will be 'ac'. The expression 'a = 5' and 'b = 10' assign integer values to the variables 'a' and 'b'. However, these assignments do not affect the concatenation operation 'd = "a" + "c"'. Here, 'a' and 'c' are string literals, and the '+' operator concatenates them, resulting in the string 'ac'. Therefore, the 'print(d)' statement will output 'ac'.

Discussion

1 comment
Sign in to comment
AZIrvThoOption: C
Sep 29, 2023

When running this code: a = 5 b = 10 d = "a" + "c" print (d) The response is: ac