name of the variable with single underscoreyou can define protected variables in python and also by using double underscore '__ in front of the variable or function name you will be able to define private members exampleclass persondef __init__(self)self fname 'aseempublic variable self __lname 'patel#private variable #outside class person(print("my name is " fnameprint("my last name is " __lnameoutputmy name is saman traceback (most recent call last)file " :/users/osou- /pycharmprojects/myfirstpythonprogramprogram py"line in print("my last name is ", __lnameattributeerror'personobject has no attribute '__lnamein this example accessing public variables outside the classthe definition is possible but cannot access private variable outside the class but we can access this private variable __lname by accessing it through function inside the class person as followexampleclass persondef __init__(self)self fname 'aseemself __lname 'pateldef printpersonname(self)return self fname +self __lname person(print("my name is ", fnameprint( printpersonname()page