Post

Python Developer
Python Developer@Python_Dv·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
34
8
95
13K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@Python_Dv Output: hello Explanation s = "hello" → s points to "hello" t = s → t also points to "hello" s = s.upper() → creates a new string "HELLO" and assigns it to s t is unchanged because strings are immutable So print(t) outputs: hello
English
0
0
13
1.2K
Earnest Codes
Earnest Codes@Earnesto037·
@Python_Dv Answer: B) hello The code works as follows: Initially, the variable s is assigned the string literal "hello". A new variable t is created and assigned the value currently held by s. Since strings are immutable in Python, this creates a separate
English
1
0
11
752
EVY TECHNO
EVY TECHNO@EvyTechno·
The answer to the Python Mind Game in the third image is B) hello. Here is a step-by-step breakdown of why the output is lowercase, followed by how this core programming concept relates to the data roles you shared: Why the answer is "hello" The trick to this "Mind Game" lies in how Python handles variable assignment and string immutability: s = "hello": A string object "hello" is created in memory, and s points to it. t = s: Now, the variable t also points to the exact same "hello" object in memory. s = s.upper(): This is the crucial part. Strings in Python are immutable (cannot be changed). The .upper() method doesn't change the original string; instead, it creates a new string "HELLO". This line reassigns s to the new uppercase version, but t is still pointing to the original lowercase "hello" object. print(t): Since t was never changed or reassigned, it prints the original value: hello.
English
0
0
5
612
Sergei Kotov
Sergei Kotov@kotov_dev·
Answer: B (hello) If you think the key is string immutability, you're wrong. The key is the = operator! › t = s → both point to "hello" › s = s.upper() → s REASSIGNED to "HELLO" › t unchanged (still "hello") For beginners: s = something creates a NEW binding. Works the same with lists, dicts, any type!
English
0
0
3
134
Jenny
Jenny@JennyTheDev·
@Python_Dv B) hello Strings are immutable in Python. t = s copies the reference, but s.upper() creates a NEW string. t still points to the original "hello"
English
0
0
1
568
Siddartha DevOps
Siddartha DevOps@SiddarthaDevops·
@Python_Dv B) hello: strings in python are immutable can not be changed. s = supper()
English
0
0
1
648
Cloud X Berry
Cloud X Berry@cloud_x_berry·
@Python_Dv hello, the last assignment to “t” is hello, so the answer would be option B “hello”
English
0
0
0
1K
DrRobotoAi MyAgenta
DrRobotoAi MyAgenta@MyagentaC68092·
@Python_Dv B, since string is immutable (unchangeable, unmodifiable), so the changed one becomes another one, while the original keeps unchanged.
English
0
0
0
77
Python Tech
Python Tech@PythonTech43716·
@Python_Dv The value of t is hello and the value string is assigned to t then s.upper() And print is the value t is hello.
English
0
0
0
34
Sir Nd
Sir Nd@Nnamdi_aqua·
@Python_Dv B - hello. t still bears the value "hello" since it's a different variable to s though holding similar value
English
0
0
0
136
Paylaş