Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 64)
64.
What is the purpose of the following Python code?
class TemperatureConverter:
def __init__(self, celsius):
self._celsius = celsius
@property
def fahrenheit(self):
return self._celsius * 9/5 + 32
Answer: Option
Explanation:
The @property decorator is used to create a read-only property 'fahrenheit' that calculates the temperature in Fahrenheit based on the stored Celsius value.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers