Basic Object Oriented Concept in Python

Object Oriented Concept in Python

Object oriented programming in Python is easy most then other OOP languages. Object oriented programming concept relates the programming to real world entities. You can reuse your code by creating multiple instance. Here import thing is to understand the concept of class and object.

Concept of Class and Object

Class – Classes are blueprint of real world situation, if you want to represent students details in terms of programming then you create a class named Student and add attributes to it as per your requirement like sname, fname, class, rollno, contactno, addr etc or any information that you want to get from Student.

Object – Objects are real instance of class created earlier (Student). You can create as much as object as per your requirement. Each object will have its own attribute associated and if you call the object you will able to get all the attributes detail associated with that object. Suppose rahul is the object of Student then rahul will carry all other infomations [sname-paul, fname-john, classs-9, addr- xyz colony]. Lets understand with code using Python in next post.

Finding largest in list elements in Python.

Largest in List of Python

This program is to find the largest among the list elements using for loop. Logic here is to store first element in variable called large and iterate the rest of the elements using for loop from 1 to length of list. Now check if the element found is greater then the variable large then assign the current element value in large and continue the same.

Program to find largest among the list elements.

Output of this will look like this. –

List elements are – [4, 5, 3, 2, 5, 7, 9, 1]
Largest element in list is – 9