Posts

Showing posts from January, 2022

Classes and Objects

Image
PYTHON OOPS CONCEPTS Like other general-purpose programming languages, Python is also an object-oriented language since its beginning. It allows us to develop applications using an Object-Oriented approach. In Python, we can easily create and use classes and objects. An object-oriented paradigm is to design the program using classes and objects. The object is related to real-world entities such as books, houses, pencils, etc. The oops concept focuses on writing the reusable code. It is a widespread technique to solve the problem by creating objects. Major principles of object-oriented programming systems are given below. Class Object Method Inheritance Polymorphism Data Abstraction Encapsulation CLASS The class can be defined as a collection of objects. It is a logical entity that has some specific attributes and methods.  For example: if you have an employee class, then it should contain an attribute and method, i.e. an email id, name, age, salary, etc. Syntax OBJECT The object is an

File Management in python

Image
PYTHON FILE HANDLING Till now, we were taking the input from the console and writing it back to the console to interact with the user. Sometimes, it is not enough to only display the data on the console. The data to be displayed may be very large, and only a limited amount of data can be displayed on the console since the memory is volatile, it is impossible to recover the programmatically generated data again and again. The file handling plays an important role when the data needs to be stored permanently into the file. A file is a named location on disk to store related information. We can access the stored information (non-volatile) after the program termination. The file-handling implementation is slightly lengthy or complicated in the other programming language, but it is easier and shorter in Python. In Python, files are treated in two modes as text or binary. The file may be in the text or binary format, and each line of a file is ended with the special character. Hence, a file