Back to questions
JuniorTheoryCommon
What does the program print?
a = (1)
b = (1,)
print(a == 1, b == 1, len(b))True False 1
- Expecting
(1)to be a tuple: parentheses around one value only group it, soais theint1anda == 1isTrue. The comma is what makes a tuple. - Expecting
(1,)to equal1:bis a tuple holding one element, and a tuple never equals anint, sob == 1isFalseandlen(b)is1.
- How do you write an empty tuple, and what is its length?
- What does
x = 1, 2assign tox?