Relationship of objects and classes

Relationship of objects and classes

Lesson Details:
June 29, 2020

I: Introduction

Learning basic python programming for beginners is essential for an individual to become proficient in the language. With the knowledge of this language, one would be able to gain employment as a programmer or work at a programming job. One will also learn how to create their own applications like games, websites, and even mobile apps. This article will be useful for those who want to learn the basics of the language.

II: Body

A: Relationship of objects and classes

The first thing that you need to learn is the relationship between objects and classes. Object-oriented programming (OOP) is commonly used in most modern programming languages today. It is a concept that is essential for an individual to grasp if they want to become proficient in the language. The first step is to understand what objects are. An object can be anything physical or non physical. Take for example an apple. It is both physical and non physical. It has properties like color, shape, weight, taste, etc. You can categorize it into other objects based on these properties. For example, you can categorize it into fruits, plants, vegetables, food items, etc. These are called sub objects. It can also be classified into computers with different features like processor speed, storage capacity, etc. These are called sub classes. Classes are defined by different data types. Once defined, they are known as object instances. They are also referred to as objects. They are created using class definitions. A class defines what properties an object has and what actions an object can perform. For example, the class definition for animals will define all animals with their properties and actions. These include their name, number of legs, characteristics, abilities, etc. The OOP concept also includes inheritance or polymorphism. Inheritance is when a new class is made with additional properties and actions from existing classes. For example, if you have a class named human being then you can create a new class named adult human being which inherits the properties of the existing class but also adds more properties like age, height, weight, etc. Polymorphism is when an action is performed using any instance of the class. For example, if you have a class named animal with actions perform_action() and perform_another_action(), then you can call either action using any instance of the class without having to change your code if the class definition changes.

B: Variables and expressions

The next thing that you need to learn is how variables and expressions work in python. A variable is like a box where we store our data in it. You can store anything in it like numbers or text or symbols or any other information that you want to keep for future reference. A variable has a name assigned to it which you use to refer to it later whenever you need it again. It also has a type assigned to it depending on what type of data it will contain in it. There are four basic data types that every variable must conform to: integer, floating point number, string and boolean. The first two types are also known as numeric data types and they each have bits and bytes assigned to them which determine their size and how much memory space they occupy in the computer’s memory. A bit occupies 1 byte while a byte occupies 8 bits. An integer is a number without decimal point while a floating point number has a decimal point after at least three digits. A string is any sequence of alphanumeric characters enclosed in quotes while a boolean has only two values: true or false. An expression is simply a statement that consists of operators and operands which acts upon values and assigns values to variables. To start your learning process in python programming, you must learn how to assign a value to a variable using an assignment operator like the equals sign (=). Assignments must follow strict rules in python programming which include:

• Must be placed at the beginning of a line

• Must be preceded by either an equal sign (=) or a colon (:)

• Can contain multiple statements separated by semicolons (;)

• Can use multiple assignment operators in one line

• Must have a single space at the end of the line before the semicolon


a = 10 # value 10 assigned to variable a

b = 10 # value 10 assigned to variable b

c = 10 # value 10 assigned to variable c

d = 10 # value 10 assigned to variable d

Course content