pub-3785248829033902 | Python: Classes #1 | - Big data with Python

| Python: Classes #1 |

In Python is called an OPL "object-oriented programming language." 

This means there is a construct in Python called a class that lets you structure your software in a particular way. Using classes, you can add consistency to your programs so that they can be used in a cleaner way. 


The best way to learn new things is to take a practical approach of the things you want to learn. Here is a fragment of code that demonstrates the use of Class statement in Python:

Æ’ python command

class TeslaInc(float):
    def __str__(self):
        return 'The best '
    def __repr__(self):
        return 'electric Car '
Car = TeslaInc(2.27)
print(str(Car))
print(repr(Car))
print(float(Car))

output

The best
electric Car
2.27


Previous
Next Post »