November 2018
Beginner
304 pages
7h 35m
English
Properties are found in other languages as getters and setters. As those terms indicate, they are used to get data and set (modify) data. To gain an understanding of getters, setters, and Python properties, we'll start with an example problem:

Here, we create a class that defines the temperature in degrees Fahrenheit. The __init__() method takes temp as an argument; it also provides a default value for temp if none is provided. A conversion method to Celsius is also provided; it simply returns the conversion value but doesn't attempt to assign any values to any variables.
A new instance is created on line 82 and ...
Read now
Unlock full access