GPYC Exam QuestionsBrowse all questions from this exam

GPYC Exam - Question 2


What are the contents of the variable x when the following is executed in a Python interactive session?

Show Answer
Correct Answer: A,C

When the expression x.split()[0][1] is evaluated, it first splits the string x into a list of words: ['So', 'you', 'want', 'a', 'GIAC', 'Certification?']. The expression then accesses the first word ('So') and retrieves the second character of that word ('o'). However, the value of x itself does not change due to this operation and remains as 'So you want a GIAC Certification?'. Given the requirement to print the value of x, the value is not altered and remains 'So'.

Discussion

7 comments
Sign in to comment
romaeOption: C
Oct 29, 2022

Answer is C - since x.split result isn't stored back to x , it prints back original x value So you want a GIAC Certification?

mrmrme
Feb 7, 2022

Equates to 'o'

AZIrvThoOption: C
Sep 29, 2023

x = "So you want a GIAC Certification?" x.split () [0] [1] print (x) When running this code, it returns "So you want a GIAC Certification?" Answer is C.

VenudharOption: C
Nov 18, 2023

The option is c

a29dc2cOption: A
Feb 6, 2024

split() isn’t stored in x

kyao
Apr 21, 2024

The answer is o

kyaoOption: C
Apr 21, 2024

My bad. Please ignore my previous answer. It should be C.