Object-Oriented Programming
At this point, it’s important to discuss object-oriented programming (or OOP). OOP is a
coding model that serves as the core principle behind major computer languages (e.g.
Java). You need to understand OOP if you want to be a skilled hacker.
The Components of an Object
Each object has methods (things it can do) and properties (states or attributes).
OOP allows programmers to link their activities with the real world. For instance, a
computer has methods (e.g. turns on, accesses the internet, launches applications, etc.) and
properties (e.g. available space, processing speed, brand, etc.). If you’ll think of OOP as a
human language, objects are nouns, methods are verbs, and properties are adjectives.
Each object belongs to a class. A computer, for example, belongs to the class called
“machines”. “Machines” is the class, “computers’ is a subclass, and “laptops” is a subsubclass.
An object gets the characteristics of its class.
Variables
Variables point to information that exists in a computer’s memory. In Python, this memory
can keep different pieces of data (e.g. strings, lists, integers, Booleans, dictionaries, real
numbers, etc.).
Variable types act like classes. The script you’ll see below shows some of these types.
Launch a text editor and type the following code:
#!usr/bin/python/
SampleStringVariable = “This is an awesome variable.”;
SampleList = [10,20,30,40,50]
SampleDictionary = {‘example’: ‘Hacker’, ‘number’: 23}
print SampleStringVariable
Précédent

- 21/94

Suivant