How to use Python string swapcase() Method

swapcase()method returns a string in which all the case are swapped based on their characters. It goes not take any arguments remember that. Syntax str.swapcase()   Examples str= “hello to this new world” printstr.swapcase()   str=”HELLO TO THIS NEW WORLD” printstr.swapcase()   str=”Hello to This new World” printstr.swapcase() When we run our program we will […]

How to use INHERITENCE in PYTHON

OOP(object oriented programming) : Programming that is based around classes and instances of those classes. OOPs programming revolves around how these classes interact and directly affect one another. One of the most imp aspect of oops is INHERITENCE.   INHERITENCE : It is when one class gains all the attributes of another class. In inheritance […]

How to use Classes in Python

CLASSES Classes in python are how you make objects. The classes themselves are the blueprint for how an object is created. For Ex- Class Duck: def quack(self): Print(“Quaaaaaaaaaack”) def walk(self): Print(“walks like a duck”) Here is the class called duck and implements couple of method called quack and walk. So when you will create the […]

How to use Python String center Method

This method returns centered in a string of length width. Padding is achieved using the specified fillchar. Default is space.   Syntax Str.center(width[,fillchar])   Parameters width – Total length of string fillchar – filler character   Example str=”this is example with string in it” print “str.center(40,’a’) : ”,str.center(40,’a’)   Result   sttr.center(40,’a’) :  aaathis is […]