Python Classes and Objects Classes and objects are the two main aspects of object-oriented programming. A class is the blueprint from which individual objects are created. In the real world, for example, there may be thousands of cars in existence, all of the same make and model. Each car wasContinue Reading

Exception Handling in Python The cause of an exception is often external to the program itself. For example, an incorrect input, a malfunctioning IO device etc. Because the program abruptly terminates on encountering an exception, it may cause damage to system resources, such as files. Hence, the exceptions should beContinue Reading

File Handling As the part of programming requirement, we have to store our data permanently for future purpose. For this requirement we should go for files. Files are very common permanent storage areas to store our data. Types of Files:There are 2 types of files Text Files:Usually we can useContinue Reading

It is an encapsulation mechanism to group related modules into a single unit. package is nothing but folder or directory which represents collection of Python modules. Any folder or directory contains file,is considered as a Python package. This file can be empty. A package can contains sub packages also.Continue Reading

Modules A group of functions, variables and classes saved to a file, which is nothing but module. Every Python file (.py) acts as a module. Ex: dharshimath.pyx=888def add(a,b): print(“The Sum:”,a+b)def product(a,b): print(“The Product:”,a*b) dharshimath module contains one variable and 2 functions. If we want to use members of module inContinue Reading

Recursive Functions A function that calls itself is known as Recursive Function. Ex: factorial(3)=3*factorial(2) =3*2*factorial(1) =3*2*1*factorial(0) =3*2*1*1 =6 factorial(n)= nfactorial(n-1) The main advantages of recursive functions are: We can reduce length of the code and improves readability We can solve complex problems very easily. Q. Write a Python Function toContinue Reading

FUNCTIONS If a group of statements is repeatedly required then it is not recommended to write these statements every timeseparately.We have to define these statements as a single unit and we can call that unit any number of times based on our requirement without rewriting. This unit is nothing butContinue Reading

Dictionary Data Structure We can use List, Tuple and Set to represent a group of individual objects as a single entity. If we want to represent a group of objects as key-value pairs then we should go for Dictionary. Ex:rollno—-namephone number–addressipaddress—domain name Duplicate keys are not allowed but values canContinue Reading

Set  Data Structure If we want to represent a group of unique values as a single entity then we should go for set. Duplicates are not allowed. Insertion order is not preserved. But we can sort the elements. Indexing and slicing not allowed for the set. Heterogeneous elements are allowed.Continue Reading

Tuple is exactly same as List except that it is immutable. i.e once we creates Tuple object,we cannot perform any changes in that object. Hence Tuple is Read Only version of List. If our data is fixed and never changes then we should go for Tuple. Insertion Order is preservedContinue Reading