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
45
9
138
22.2K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Output: B) 125 a is a string "123", int(a) converts it to the number 123. Then 123 + 2 = 125.
English
0
0
13
1.8K
Neus Lorenzo
Neus Lorenzo@NewsNeus·
@PythonPr B. Explanation: a = "123" assigns a string containing numeric characters. b = int(a) converts that string to the integer 123. print(b + 2) performs integer addition: 123 + 2 = 125. No error because "123" is a valid numeric string and can be converted to an integer using int().
English
0
0
3
240
Elinah
Elinah@Elinah____·
@PythonPr B) 125 A is a string. Converting the data value in a to integer will produce 123. Therefore, b + 2 will give 125.
English
0
0
2
940
SKG
SKG@Suresh03405842·
@PythonPr Ans: B Converting string to Integer and adding 2. 123+2 = 125.
English
0
0
2
970
Coder Maya
Coder Maya@maya_m111·
@PythonPr Answer is B,the variable a is changed to become interger in b
English
0
0
1
123
Yemi Fred
Yemi Fred@PeterYemi95091·
@PythonPr a= "123" # a string b = int(a) # converting a string to integer print (b +2) # 0utput 125
English
0
0
1
325
God's Child
God's Child@Unique____tips·
@PythonPr The correct answer is B) 125. ​a = "123": The variable a is assigned a string (text) value of "123". ​b = int(a): The int() function converts the string "123" into the integer (number) 123 and stores it in b. ​print(b + 2): Python performs mathematical addition between integer
English
0
0
0
3
Paylaş