Post

Python Developer
Python Developer@Python_Dv·
Comment below the output! 😃👇
Python Developer tweet media
English
10
4
74
12.3K
asteroid
asteroid@earth_asteroid·
@Python_Dv The right answer is B, because join() method creates the string "hello" which is then assigned to variable b, but "a" and "b" are different ovjects in memory. If I may point a mistake in the picture, a quotation mark lacks before .join method
English
2
0
3
932
Othieno Michael Edwards
Othieno Michael Edwards@EdwardsOthieno·
@Python_Dv 1. Is operator checks if variables point to the same object in memory 2. == checks if the 2 variables have same values/elements 3. In python, the join() function creates a new object in memory 4. a is b, FALSE (object have separate memories) 5. a==b, TRUE (same object values)
English
0
0
2
252
Karathanasis Athanasios
Karathanasis Athanasios@k_athanasi·
@Python_Dv Correct answer: B — False True == compares values, is compares object identity. "hello" is a literal (often interned), while "".join(...) creates a runtime string, same type and value, but different object identity (different instance), i.e. distinct objects in memory.
English
1
0
1
718
Paylaş