Filter
Exclude
Time range
-
Near
#Python Pop Quiz πŸβ“ What is the output of the following code? A) Python B) Python rocks! C) Python rocks! Python D) Pythonrocks! Python
6
1
20
4,032
#Python Pop Quiz πŸβ“ What is the output of the following code? A) Python B) Python rocks! C) Python rocks! Python D) Pythonrocks! Python
8
1
11
2,610
#Python Pop Quiz πŸβ“ What is the output of the following code? A) Python B) Python rocks! C) Python rocks! Python D) Pythonrocks! Python
7
3
28
3,150
πŸš€ We are looking for Live Transcribers/Stenographers at #PyConIndia2024 ! Any leads are most welcome. πŸ™ πŸ“… #Conference πŸ™οΈ #Bengaluru 🐍 #PythonRocks πŸ’» #CodeLife 🌐 #TechTalks 🎀 #DevCommunity πŸŽ‰ #TranscribersWanted
1
15
23
1,492
x refers to a new value "Pythonrocks!" and y continues to refer to the old value "Python" At this stage, let's see what print(x, y) do. Recall that if we pass multiple arguments to print, by default, they are printed with spaces separating them. Hence
1
2
102
Replying to @driscollis
Answer: D. Pythonrocks! Python Solution: x = y = "Python" assigns the string "Python" to y, and assigns y to x So, both x and y refer to the same string value "Python" x = "rocks!" This is equivalent to x = x "rocks!" Hence, x is being *reassigned* to a new value
2
1
4
448
#Python Pop Quiz πŸβ“ What is the output of the following code? A) Python B) Python rocks! C) Python rocks! Python D) Pythonrocks! Python
15
2
35
9,127
24 Dec 2023
Replying to @BitsLovers
so cool to see you diving into python and its flexibility love seeing your passion for coding and devops keep it up #codingjourney #pythonrocks #devopsenthusiast
1
1
24 Dec 2023
Replying to @AndroskiS @OpenAI
totally get that feeling when your code is more comments than commands πŸ˜„ its awesome that youre documenting well keep it up #codinglife #pythonrocks
1
10
23 Dec 2023
Replying to @thevibengineer
wow day 16 and going strong with those problems of the day keep crushing it with python coding power on your side #codingheroes #pythonrocks #keepitup πŸ’ͺβœ¨πŸ’»
1
1
22
23 Dec 2023
oh i feel you python magic never fails to impress keep on coding those sleek one-liners #pythonrocks 🐍✨
12
Replying to @SattarFalahati
🐍 For me, I'd pick Python! Python is so popular among developers because of its simplicity and readability, which often translates to faster development and less code. Plus, its versatility across various domains can't be beaten! #PythonRocks πŸš€
3
92
Replying to @driscollis
D . Pythonrocks! Puthon
1
41
Replying to @driscollis
The answer is D) Pythonrocks! Python This is because = makes a new object every time so now x and y both are independent variables.
3
322
Replying to @driscollis
The answer is D) Pythonrocks! Python πŸ’‘The key learning point of this Problem is about the distinction between mutable and immutable objects in Python. Let's see how ---------- Here we need to know how Python handles the assignment of variables based on if a variable is mutable or immutable and how the use of the ` =` operator can affect these variables. 1. `x = y = "Python"`: This is called a chained assignment. This line of code is setting both `x` and `y` to the string "Python". The order of operations here is important. It actually works from right to left. First, the string "Python" is assigned to the variable `y`, and then `y` (which now holds "Python") is assigned to `x`. Both `x` and `y` are now pointing to the same object in memory. 2. `x = "rocks!"`: This line uses the ` =` operator which is shorthand for `x = x "rocks!"`. But here's the critical point: in Python, strings are immutable. 3. πŸ’‘ This means that, while the value of `x` appears to change, what really happens is that a new object `"Pythonrocks!"` is created in memory, and `x` is updated to point to this new object. 4. `y` remains pointing to the original "Python" object. This is because when we do `x = "rocks!"`, we're not changing the original string that `x` was referencing, but instead creating a new string and updating `x` to reference that new object. 5. `print(x, y)`: Β The values of `x` and `y`, at this point in the code are "Pythonrocks!" and "Python", respectively. Hence the output: `"Pythonrocks! Python"`. ---------------- πŸ’‘So the theory in play here is the distinction between mutable and immutable objects in Python. When `x` and `y` were first defined, they both pointed to the same object in memory. If that object was mutable (like a list), changes to it would be reflected in both `x` and `y`. But since strings are immutable in Python, when we use the ` =` operator to try and "change" `x`, it instead creates a new object and changes `x` to point to that new object, leaving `y` still pointing to the original "Python" object. ---------------------- πŸ‘‰ If you enjoyed this explanation: βœ…1. Give me a follow @rohanpaul_ai for more of this every day and βœ…2. Like & Retweet this tweet: βœ…3. Subscribe to my MachineLearning YouTube channel - youtube.com/@RohanPaul-AI

5
5
70
6,298
Replying to @driscollis
>>> x=y="Python" >>> x ="rocks!" >>> print(x,y) Pythonrocks! Python
2
1,608
9 Jul 2023
Replying to @driscollis
The answer is D. Here in the first line both x and y are assigned the string "python". x = means adding "rocks!" Thanks the former value of x. Hence, print(x, y) will result in Pythonrocks! Python.
5
2,798
#Python Pop Quiz πŸβ“ What is the output of the following code? A) Python B) Python rocks! C) Python rocks! Python D) Pythonrocks! Python
18
4
71
21,656