GPYC Exam QuestionsBrowse all questions from this exam

GPYC Exam - Question 6


Review the following code, written in Python. What are the contents of variable a?

Show Answer
Correct Answer: B

The code creates two sets, a and b, containing the specified strings. The update method on a adds all elements of set b to set a. Since sets are unordered collections in Python, the final contents of a will be all unique items from both sets a and b. Therefore, the contents of variable a are 'dandelion', 'rose', 'cat', 'violet', 'bird', and 'dog'.

Discussion

1 comment
Sign in to comment
VenudharOption: D
Nov 18, 2023

The option isD