True


Definition
Keyword Implies not False.

Syntax
True

Parameters
N/A

Examples
If statement is used on the method of requests.request() to get the open link in the webbrowser.
 >>> import requests
>>> re=requests.request('Get','http://www.pythonlake.com')
>>> re
<Response [200]>
>>> if re.ok==True:
...     webbrowser.open_new('www.adilwaseem.com')
...     
True
>>> 


str.isspace().__ne__(True)
The following are outcome:
 >>> str.isspace("").__eq__(False)
True
>>> x=""
>>> x.isspace().__ne__(True)
True


The tkinter.Entry is used to check the string characteristics through string methods.

master=Tk()
master.title("String methods")

def cap():
    try:
        c=str.capitalize(s.get())
        s.set(c)
        
        pass

def cfold():
    try:
        c=str.casefold(s.get())
        s.set(c)
        
    except ValueError:
        pass

def ifier():
    try:
        if str.isidentifier(s.get())==True:
            s.set("Yes")
        
        else:
            s.set("No")
        
    except ValueError:
        pass

def ipace():
    try:
        if str.isspace(s.get())==True:
            s.set("Yes")
        
        else:
            s.set("No")

    except ValueError:
        pass

def iric():
    try:
       if str.isnumeric(s.get())==True:
           s.set("Yes")
       else:
           s.set("No")        
                
    except ValueError:
        pass

def ower():
    try:
        if str.islower(s.get())==True:
            s.set("Yes")
        
        else:
            s.set("No")        
        
    except ValueError:
        pass

def inum():
    try:
        if str.isalnum(s.get())==True:
            s.set("Yes")
        
        else:
            s.set("No")        
    except ValueError:
        pass

def imal():
    try:
        if str.isdecimal(s.get())==True:
            s.set("Yes")
        
        else:
            s.set("No")
        
    except ValueError:
        pass

    

def igit():
    try:
        if str.isdigit(s.get())==True:
            s.set("Yes")
        
        else:
            s.set("No")
        
    except ValueError:
        pass


def clr():
    try:
        s.set("")
        
              
    except ValueError:
        pass



entry=Entry(master, textvariable=s)
entry.grid(row=0, columnspan=4, sticky=W+E)


button_capitalize=Button(master, text="capitalize", width=10, command=cap)
button_capitalize.grid(row=2, column=0)

button_casefold=Button(master, text="casefold",width=10, command=cfold)
button_casefold.grid(row=2, column=1)

button_isidentifier=Button(master, text="isidentifier",width=10,command=ifier)
button_isidentifier.grid(row=2, column=2)


button_isspace=Button(master, text="isspace",width=10, command=ipace)
button_isspace.grid(row=3, column=0)

button_endswith=Button(master, text="endswith", width=10, command=iric)
button_endswith.grid(row=3, column=1)

button_islower=Button(master, text="islower",width=10, command=ower)
button_islower.grid(row=3, column=2)



button_isalnum=Button(master, text="isalnum",width=10, command=inum)
button_isalnum.grid(row=4, column=0)

button_isdecimal=Button(master, text="isdecimal",width=10, command=imal)
button_isdecimal.grid(row=4, column=1)

button_isdigit=Button(master, text="isdigit",width=10, command=igit)
button_isdigit.grid(row=4, column=2)

button_clear=Button(master, text="Clear", command=clr )
button_clear.grid(row=5, columnspan=3,sticky=W+E)












str(int())is not int(str())-> True
The returns are :
 >>> type("Python Research Centre".rfind("Centre"))==type(str("Python Research Centre".rfind("Centre")))
False
>>> type("Python Research Centre".rfind("Centre")) is not type(str("Python Research Centre".rfind("Centre")))
True
>>> "Python Research Centre".rfind("Centre") is not str(int("Python Research Centre".rfind("Centre")))
True
>>> "Python Research Centre".rfind("Centre").__eq__str(int("Python Research Centre".rfind("Centre")))
False
>>> "Python Research Centre".rfind("Centre") .__eq__int(str("Python Research Centre".rfind("Centre")))
True
>>>


str.rstrip().__eq__(str)-> True
The returns are:
 >>> "Python Lake ".rstrip()
'Python Lake'
>>> "Python Lake                            ".rstrip().__gt__("Python Lake ".rstrip())
False
>>> "Python Lake                            ".rstrip().__eq__("Python Lake ".rstrip())
True
>>> "Python Lake                             ".rstrip().__eq__("Python Lake")
True
>>> "Python Lake                             ".rstrip().__eq__(str("Python Lake"))
True
>>> type("Python Lake ".rstrip())
<class 'str'>
>>>


str.splitlines()==list-> True
Equal test on conducted on the string and other str.splitlines.
 >>> x="Python Reserch Centre"
>>> x.splitlines()
['Python Reserch Centre']
>>> type(x.splitlines())
<class 'list'>
>>> y=x.splitlines()
>>> x==y
False
>>> x.splitlines().__eq__(['Python Reserch Centre'])
True
>>> x.splitlines()==(['Python Reserch Centre'])
True
>>> test1=x.splitlines()
>>> test2=['Python Reserch Centre']
>>> test1==test2
True
>>> 

str(int()) not equal int(str())
The returns are :
 >>> type("Python Research Centre".rfind("Centre"))==type(str("Python Research Centre".rfind("Centre")))
False
>>> type("Python Research Centre".rfind("Centre")) is not type(str("Python Research Centre".rfind("Centre")))
True
>>> "Python Research Centre".rfind("Centre") is not str(int("Python Research Centre".rfind("Centre")))
True
>>> "Python Research Centre".rfind("Centre").__eq__str(int("Python Research Centre".rfind("Centre")))
False
>>> "Python Research Centre".rfind("Centre") .__eq__int(str("Python Research Centre".rfind("Centre")))
True
>>>


True==True
The return are following:
 >>> x="PYTHON LAKE".isupper()
>>> y="python lake".upper()
>>> x==y
False
>>> "PYTHON LAKE".isupper()==("python lake".upper())
False
>>> "PYTHON LAKE".isupper()
True
>>> "python lake".upper().__eq__("PYTHON LAKE")
True
>>> True.__eq__(True)
True
>>>


string==string-> True
Returns are following:
 >>> list=["Python", "Research", "Centre"]
>>> "Lake".join(list)
'PythonLakeResearchLakeCentre'
>>> set={"Pyhton", "Research", "Centre"}
>>> "Lake".join(set)
'ResearchLakePyhtonLakeCentre'
>>> tuple=("Pyhton", "Research", "Centre")
>>> "Lake".join(tuple)
'PyhtonLakeResearchLakeCentre'
>>> list==set
False
>>> set==tuple
False
>>> False==False
True
>>> "Lake".join(tuple)=="Lake".join(set)
False
>>> 'PyhtonLakeResearchLakeCentre'=='ResearchLakePyhtonLakeCentre'
False
>>> 'PythonLakeResearchLakeCentre'=='PythonLakeResearchLakeCentre'
True
>>>


str.istitle().__eq__(True)
The return are equal to:
 >>> 
>>> "Python Lake".istitle().__eq__(True)
True
>>> "Python Lake".istitle().__ne__(False)
True
>>> "Python lake".istitle().__eq__(True)
False
>>> "python lake".istitle().__eq__(True)
False
>>> "PYTHON LAKE".istitle().__eq__(True)
False
>>>


The return are as:
 >>> "Python Lake".isnumeric()
False
>>> str.isnumeric("Python Lake")
False
>>> x="Python Lake"
>>> x.isnumeric()
False
>>> x.isnumeric().__eq__(True)
False
>>> y=x.isnumeric()
>>> x is y
False


def (Decimal attribute)
The method returns with Decimal attribute test as through define function and if statement.
 from decimal import Decimal

def test (a,b,c,d,e,f,g,h,i):

    
    if a==True:
        print("The Decimal(",value1,")is canonical.")
    else:
        print("The Decimal(",value1,")is not canonical.")
        
       
    if b==True:
        print("The Decimal(",value2,")is finite.")
    else:
        print("The Decimal(",value2,")is not finite.")


    if c==True:
        print("The Decimal(",value3,")is infinite.")
    else:
        print("The Decimal(",value3,")is not infinite.")


    if d==True:
        print("The Decimal(",value4,")is nan.")
    else:
        print("The Decimal(",value4,")is not nan.")


    if e==True:
        print("The Decimal(",value5,")is normal.")
    else:
        print("The Decimal(",value5,")is not normal.")
              

    if f==True:
        print("The Decimal(",value6,")is signed.")
    else:
        print("The Decimal(",value6,")is not signed.")


    if g==True:
        print("The Decimal(",value7,")is snan.")
    else:
        print("The Decimal(",value7,")is not snan.")


    if h==True:
        print("The Decimal(",value8,")is subnormal.")
    else:
        print("The Decimal(",value8,")is not subnormal.")


    if i==True:
        print("The Decimal(",value9,")is zero.")
    else:
        print("The Decimal(",value9,")is not zero.")


value1=1.1
value2=-2.1
value3='infinity'
value4=0
value5=1.21
value6=10
value7=.50
value8=.12
value9=.21

test(value1,value2,value3, value4, value5,value6,value7, value8, value9)

>>> 
The Decimal( 1.1 )is canonical.
The Decimal( -2.1 )is finite.
The Decimal( infinity )is infinite.
The Decimal( 0 )is not nan.
The Decimal( 1.21 )is normal.
The Decimal( 10 )is not signed.
The Decimal( 0.5 )is not snan.
The Decimal( 0.12 )is not subnormal.
The Decimal( 0.21 )is not zero.
>>>


class.....: def __init__()......:....string==True
The function tested whether the string value is single word, or contain non-string values through input().
 class str_methods():
    def __init__(self, a,b,c):

        identifier=str.isidentifier(a)

        if str.isidentifier(a).__eq__(True):
            print("Full name should not contain special characters or numbers")
            
        else:
            print("Your full not name accepted")

        
      
        alpha=str.isalpha(b)
        
        if alpha.__ne__(False):
            print("Full name accepted")

            lower=str.lower(c)
            if lower.__eq__(str.lower(c)):
                 str.upper(c)
                 print("System convert your name to uppercase:", str.upper(c))
            else:
                 print("Your name accepted")

        else:
            print("Full name can't be one word")

                    

input_text=input("Please enter  your full name: ")

str_methods(input_text, input_text,input_text)
    
          

>>> 
Please enter your full name: Adil22
Full name should not contain special characters or numbers
Full name can't be one word
>>>        



Comments