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
42
12
116
17.7K
Sergei Kotov
Sergei Kotov@kotov_dev·
Answer: B) hello HELLO Step by step: › x = 'hello' (original string) › y = x.upper() creates a NEW string 'HELLO' › x stays unchanged at 'hello' For beginners: String methods DON'T modify the original! They return a new string. This is because strings are immutable in Python.
English
0
0
12
1.5K
Jenny
Jenny@JennyTheDev·
@PythonPr B) hello HELLO .upper() returns a new string, doesn't modify the original. Strings are immutable in Python
English
0
0
7
943
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr B — hello HELLO upper() doesn’t modify x, it creates a new string for y.
English
0
0
4
745
Cool_guy11
Cool_guy11@Intel_Gf_11·
@PythonPr B....Converts each argument to a string Joins them with a separator Outputs the result
English
0
0
1
40
Noem
Noem@Noemisage123·
@PythonPr B, my guess is upper() means uppercase so y is HELLO
English
0
0
1
55
K0D€D^
K0D€D^@jaiyedkoded1·
@PythonPr as a beginner I’d say option b
English
0
0
0
19
Ophelia Pagve
Ophelia Pagve@OPagve98615·
@PythonPr since '.upper()' converts all strings in to capital cases, the print statement will give the answer B.
English
0
0
0
87
Gizzy Codes
Gizzy Codes@GafarIb42311292·
@PythonPr The answer is B This is because before the y variable is being printed, it's value has been declared to be the upper case of the x variable. So we're printing (x, y), which gives hello (x) and HELLO (y) 👍
English
0
0
0
95
Victon 🐾
Victon 🐾@Vic_Nons·
@PythonPr Hi, can a 9year learn Python basics? If yes, what idle is adviced?
English
0
0
0
26
Paylaş