What is a constructor function? The constructor function is the function that is run by default when the Python object is created. So what is this function? This function is the Python constructor function. Let’s look at the output - CAR - 1 -Īs you can see, both objects have the same properties, so how can we create different types of objects? Let’s have a look. And this is our general class creation outline. So let’s create a class right away.įor this, we will use the class keyword in Python. It showed us that these data types you see are a class type. Let’s look at the data types we learned earlier print(type(list)) For example, all cars have a brand, model, price, color, etc. Like these data types in classes, Python is also a data type.Ĭlasses are used to define groups or sets with common properties. For example lists, tuples, dictionaries etc. So what is class? We have seen some data types in our previous blog posts. Yes, we will create our objects with the help of classes. Ok, we learned what a beautiful object is, so how do we create the objects? So let’s get a headline. So how do we create their functions? The functions of the object are We will create it with the help of functions or methods. We said that an object has properties, but what are the properties of the objects we create? Data types, operators, etc. Now let’s compare the objects in real life with the objects we create in software. At the same time, we will make some operations on these objects. We will give some properties to these objects. Here we will create objects like computer object. are functions that allow this computer to perform some work. At the same time, the computer’s power button, keys, etc. For example, the color, processor speed and brand of your computer, some features of the computer. These objects have some properties and functions. There is no need to go far, the one you are using while reading this article computer, phone or tablet is an object. How Does? When we look around, there are many objects around us. Object-oriented programming is the real-life version of software. Object-oriented programming is a software development method. Ease of adding and reusing the codes in another project because you have divided them into modules.Easier development and extension of the project.In this way, the codes you write with object-oriented programming Because writing readable and efficient code is just as important as writing code. Finally, if you want to be a good software developer, you definitely have to know.You will have to use it when you have to divide things up when you are faced with very large projects.You must learn to read code written in object-oriented programming and understand what it is.Then why to the question of object-oriented programming? Let’s answer. If you are learning object-oriented programming for the first time, you are very lucky to learn with Python. Because object-oriented programming in Python is very simple, especially when you compare it with other programming languages. Well then you will say, why am I learning object-oriented programming? Now that I have told you why you should use object-oriented programming, then you will see that knowing object-oriented programming is a necessity. Python does not force you to use object-oriented programming. Especially in Python, you can do very good things without knowing object-oriented programming. You don’t have to know object-oriented programming. I’m sure you have in mind why object-oriented programming? Do I have to know object-oriented programming? There are such questions.
0 Comments
Leave a Reply. |