Posts

Simplifying Boolean Algebra

De Morgan's Law "Either logical function AND or OR may be replaced by each other, given certain changes to the equation." NOT (A OR B) = (NOT A) AND (NOT V) Distribution "Multiplying or factoring of an expression" A AND (B OR C) =  (A AND B) OR (A AND C) Association "Allows for removal of brackets from an expression and regrouping of variables" A OR (B OR C) = (A OR B) OR C = A OR B OR C Commutation "The order of application of two separate values does not matter" A AND B = B AND A Double Negation "If you reverse something twice, you end up back where you started" THE NOT NOT OF A = A. Absorption  "The second term inside the bracket can always be eliminated and 'absorbed' by the term outside the bracket if the given conditions are met" "Rules: Operators outside and inside bracket must be different. The term outside bracket must also be inside the bracket." X OR

Symmetric & Asymmetric Encryption

Symmetric Encryption - Private Key Symmetric encryption is a type of encryption where only one key (a secret key) is used to both encrypt and decrypt electronic information. The entities communicating via symmetric encryption must exchange the key so that it can be used in the decryption process. Asymmetric Encryption - Public Key One public key, one private key. A public key is used to encrypt which everyone can see and then the private key is unique to each user to unlock.  Digital Signatures Used to verify the data has come from a genuine source and no malicious files are contained. Hashing An algorithm is used to convert data into a numerical file. It can only be done one way so cannot be reverse engineered so data is secured. Once a user enters data the algorithm can be used to perform the same hash on that data and then data can be compared for passwords etc. 

Passing Parameters into a object in Python

Image
Once objects are created from classes in Python, they can be made unique from other objects made from the same class by giving them different data. This is done by giving the attributes unique data. For example, an attribute of a class could be 'name'. So we could give different objects made with that class, different names. This is done by adding data to the class by putting this data in brackets next to the class name when it is called. bob = human("Bob", "Male", "British")

Programming a Class in Python

Image
To define a class, it is similar to a function: class [insert name of class here](): Then underneath this attributes can be defined. A class constructor has to be used: def __init__ Self must be then added to the brackets first, this is used so each individual object that is created using this class can keep hold of its own attributes over time - so the object can refer to its 'own data': (self, [attributes here]): Attributes are assigned to variables so they can be accessed throughout the object.  (self, nationality = "British", gender = "male" ):             self.nationality = nationality             self.gender = gender Once the attributes have been created, methods (functions of the class) can also be added, this example is what would be required to make the 'human object' speak: def speak(self):          print("Hello my gender is: ", self.gender) Once the class has been created with attribut

UML Diagram

Image
A UML diagram represents the class. The top section states the class name, the second section shows the classes' attributes and then the third section displays the methods. Using the example object of a human:

Advantages of OOP

Advantages of OOP, using the example of a racing game: - Instead of individually creating variables to describe an object and then creating similar variables to describe similar objects, a singular blueprint (class) can be created which multiple objects can be created off. - This way we are only defining the car once - more efficient for programmers, using less storage and easy to keep track of data.

Object Oriented Programming - Key Terms

Object-Oriented Programming - involves solutions being constructed by means of objects that interact with each other. Using objects means programs can be broken down into parts. Classes - templates used in OOP to construct objects. Attributes - variables associated with it. Methods - subroutines that form the actions an object carries out. Instantiation - The creation of objects is called ‘instantiation’. When creating an object we create an instance of the class. Inheritance - where a class retains the methods and attributes of its parent class as well as having its own. Means one class can be coded and used multiple times for similar objects. Encapsulation - is the process of keeping objects attributes private so they can only be accessed and changed via public methods.  Means object can only behave in expected ways, no unforeseen circumstances. Polymorphism - means that objects of different types can be treated in the same way.