Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
20
8
92
8.9K
Sergei Kotov
Sergei Kotov@kotov_dev·
@PythonPr Answer: e) PytnuF Step by step: › "Python"[0:3] = "Pyt" (first 3 chars) › "Fun"[::-1] = "nuF" (reversed) › "Pyt" + "nuF" = "PytnuF" For beginners: [::-1] is the reverse trick! The -1 step means "go backwards". [0:3] gets indices 0,1,2 (stops BEFORE 3).
English
0
1
7
663
Jenny
Jenny@JennyTheDev·
@PythonPr e) PytnuF Slicing + reverse = classic interview trap
English
0
1
4
491
ANKIT 𓃱
ANKIT 𓃱@A9kitSingh·
@PythonPr Answer is E) PytnuF "Python"[0:3] gives "Pyt" and "Fun"[::-1] reverses to "nuF". Concatenating them results in "PytnuF".
Dansk
0
0
1
111
Raj🐍 | Python Learner/Coder
Raj🐍 | Python Learner/Coder@Its_Just_Raj·
@PythonPr e) option because the first slice will give Pyt and the second is reverse of Fun which gives nuF so the final answer is PytnuF
English
0
0
1
77
Siddartha DevOps
Siddartha DevOps@SiddarthaDevops·
@PythonPr Ans: e) PytnuF "Python" [0:3] string slicing format start: end start index 0-- 'p' index 3 not included = Pyt "Fun"[::-1] [::-1] means reverse the string= nuF finally ans: PytnuF
Dansk
0
0
1
125
Laxman 🧮🐧
Laxman 🧮🐧@CodeWithBinary·
@PythonPr Ans : e) PytnuF "Fun"[::-1] => reverse of Fun => nuF "Python"[0:3] => slicing till index 2 => Pyt str + str => concatenation operation
Dansk
0
0
0
8
Tanaka Hina 田中 陽菜
Tanaka Hina 田中 陽菜@Hina_TokyoMath·
@PythonPr 1 : python [0:3] takes indices 0, 1, and 2, giving us pyt 👉 the end index is exclusive ✌️ 2 : fun [::-1] uses a negative step to reverse the string, giving us nuF. 3 : concatenate them: pytnuF.
English
0
0
0
10
공유