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
25
18
142
10.2K
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer: 17 The code creates an object of the Book class and sets its price. First, an instance obj of the Book class is created. Then, the set_price(15) method is called on the obj instance. Inside this method, self._price is set to 15 + 1, which is 16.
English
1
0
10
503
Roby
Roby@RobyDread·
@PythonPr Esto imprime 17 valor = 15 val + 1 - - - - >16 __price +1 - - >17 Las expresiones val y __price aumentan el valor en 1 cada una 15+1+1=17 print - - - - > 17
Español
0
0
4
251
Othieno Michael Edwards
Othieno Michael Edwards@EdwardsOthieno·
@PythonPr 1. obj.set_price(15) calls on the set_price method resulting into a value 16 getting saved in the callers 2. print(obj.get_price()) calls on the get_price method which fetches the value 16 in the callers and adds to 1 to returns 17 3. Output on the console will be 17
English
0
0
3
387
Manasseh
Manasseh@zy_uglyvillian·
@PythonPr Are those underscores double or single?
English
0
0
1
92
DigitalNtech
DigitalNtech@DigitalNtech·
@PythonPr 17 because in the first function of the Book class, val returns 15, so 15 + 1 = 16, and in the second function, there is a return from the first function, which is 16, so 16 + 1 = 17.
English
0
0
0
43
Daniel Titi
Daniel Titi@DanielTiti19601·
@PythonPr 17 parce que il ya incrémentation de +1 ..au niveau de la valeur 15 ... Quand il appel la classe il donne un nombre .. au niveau de la variable Val.. ensuite il ajoute 1. Ensuite il appel de nouveau... la nouvelle valeur 16 ..qui nous donne un résultat 17
Français
0
0
0
7
Rinnaf
Rinnaf@Rinnaf_·
@PythonPr 17, can u make this harder please, like this is a joke
English
0
0
0
5
Paylaş