Skip to main content

Posts

Showing posts with the label oop with python

what is polymorphism?

Introduction: polymorphism is one of the many concepts in object oriented programming. I have previously discussed in details about different parts of object oriented programming in this OOPs post . In this post, we will discuss about polymorphism. Definition: In object oriented programming using a function for many purposes is termed as polymorphism. Polymorphism is a way to use the same function name, while it operates differently based on different parameters and classes it occurs in. I will explain it with a small example now. Example: Look at the following code: class examplesome:    def __init__(self,a,b,c):       self.a = a       self.b = b       self.c = c    def funct(self):       return self.a+self.b+self.c class examplesum:    def __init__(self,a,b):       self.a = a ...

Pygame tutorial

Before I introduce: I have a long desire to develop some games I can play. And recently, I have been able to learn the first few steps of that. I have created a prototype of the famous and one of the most ancient games,  pong . My version of this game currently do not contain score boards, or starting screen. The game somehow looks like this: Here the green dashes are the players, the name of the game is two player pong, and the white square is the box. I will write a thorough tutorial on the code, which is on my github, about how to develop an easy game like this. You can check my github page for the game  here .  Hope to see you soon, on the hands on tutorial session to be uploaded here on this blog. Introduction: First things first. I have developed the game using pygame in a jupyter notebook. So, first consider the imports as below: I have used the template created by chris of Kidscancode. However, there are multiple changes. In this case, I ha...

object oriented programming with python

Introduction: Object oriented programming is the newest style of programming. In the history of programming there have been three types of programming. The first style, which can be considered programming in which sense we use programming nowadays, was structural programming . This was really low level programming languages, and even C falls in the same. Then came the functional programming , when, relatively bigger problems came into picture and people started to break down them into small small problems, wrote functions for them, and after that "stitched" them together to solve the main problems. Many of the similar low level languages were of this type. But, then came object oriented programming , which was way cooler and smarter than all these. This abstracted the data out into objects which had actions associated to do, thus created a faster, much more reusable way to deal with problems. This, basically is the current standard. Python , java(partially at ...