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
22
15
162
13.5K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Correct answer: C) 52 Explanation: x = "10" creates a string. x += "5" concatenates strings → "105". int(x) converts it to 105. 105 // 2 is floor division → 52.
English
0
0
18
617
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer: c) 52 This demonstrates basic Python string manipulation and integer division: Line 1: The variable x is initialized as a string with the value "10". Line 2: The string "5" is appended to the current value of x (string concatenation). This changes the
English
1
0
6
365
Antonio Dinkins
Antonio Dinkins@AntonioDinkins3·
@PythonPr C. Int converts the string 105 to an integer and // is the integer division operator so dividing 105 by 2 isn’t 52.5 but 52.
English
0
0
2
269
CodeToRobots
CodeToRobots@CodeToRobots·
@PythonPr Answer= 52 Adding strings together concatenate them. So giving us "105". Casting the results into int() converts it into an integer, so now we ve 105. // Is called floor division operator. It divides then discard the decimal part, thus giving us 52
English
0
0
1
219
Prime Dev Digital Lab
Prime Dev Digital Lab@ODINAKA_ODINAKA·
@PythonPr C) 52 x = '10' the quotes mean 10 is treated as a string. x += '5' since both values are strings, we concatenate x becomes '105'. res = int(x) // 2 int converts x to an integer 105, // performs floor division. 105 divided by 2 results in 52, with the decimal part dropped.
English
0
0
1
144
Ifechukwude Nwoko
Ifechukwude Nwoko@IFECHUKWUD37623·
@PythonPr 52 Both strings are immutable so it will concatenate (105) and divide //2
English
0
0
1
92
Paylaş