Python‎ > ‎Built-in‎ > ‎

### int()

Introduction
The numeric function int(x) will convert the string into the integer. Python can't compute the string and integer and only way available to convert them into the integer before computing these.

Syntax
int(x)

Parameters
x=number

Examples
converting string into integer.
 >>> int("134433")134433>>> x="1234">>> int(x)1234

sum(int())
The method sum() the int() value.
 >>> x="2232">>> y=33232>>>sum( int(x), y)35464

The digital number are obtained through converted to integer through int().
 >>>import string >>> x=string.digits>>> int(x)123456789>>>

int(round(operator.sub(a,b)))
The method returns with the for loop after finding the subtraction of random values.
 import operatorimport randoma=random.triangular(7,14)b=random.uniform(2,5)x=int(round(operator.sub(a,b)))for i in range(x, 30):    print(i)    if i.__ge__(30):        b=int(round(random.paretovariate(3)))        print(i)>>> 34567891011121314151617181920212223242526272829>>>

Return with perimeter of bedroom through input().
 print("Python Lake will find Perimeter, please enter following information")l=int(input("Enter length of bedroom: "))w=int(input("Enter length of width: "))p= 2*l+2*wprint("Perimeter of Bedroom is " ,p,)>>> Python Lake will find Perimeter, please enter following informationEnter length of bedroom: 10Enter length of width: 15Perimeter of Bedroom is 50>>>

int(Decimal)
The method computed the int(value) of the decimal and then run loop through range() function.
 from decimal import Decimalfor i in range(a,10):    print(i)    print(i/Decimal(1.1).log10())        >>>00E+29124.15885792809678504023429545248.31771585619357008046859090372.47657378429035512070288634496.635431712387140160937181795120.79428964048392520117147726144.95314756858071024140577277169.11200549667749528164006818193.27086342477428032187436369217.4297213528710653621086590>>>

int(max(set(Decimal())))
The returns are following:
 from decimal import Decimalimport itertoolsset1={Decimal(0.1).to_integral_value(),Decimal(1.9).to_integral_exact(),                        Decimal(1.5000001).to_integral(), Decimal(10).shift(2)}set2={Decimal(1).scaleb(0),Decimal(1).remainder_near(2),Decimal(1.0000).normalize()}print("The decimal values of set1 are:", set1)print("The decimal values of set2 are: ", set2)max_set1=int(max({Decimal(0.1).to_integral_value(),Decimal(1.9).to_integral_exact(),Decimal(1.5000001).to_integral(), Decimal(10).shift(2)}))print("The maximum integer value in set1 is: ",max_set1)min_set2=int(min({Decimal(1).scaleb(0),Decimal(1).remainder_near(2),Decimal(1.0000).normalize()}))print("The minimum integer value in set2 is:",min_set2)set3=max_set1.__add__(min_set2)print("The set1 added by set2 is: ", set3) set4=max_set1.__lt__(min_set2)print("The max_set1 is lessor than min_set2:", set4)x=set1.difference(set2)rint("The set1 difference to set2 is :", x)>>> The decimal values of set1 are: {Decimal('1000'), Decimal('0'), Decimal('2')}The decimal values of set2 are: {Decimal('1')}The maximum integer value in set1 is: 1000The minimum integer value in set2 is: 1The set1 added by set2 is: 1001The max_set1 is lessor than min_set2: FalseThe set1 difference to set2 is : {Decimal('1000'), Decimal('0'), Decimal('2')}>>>

int(str())
The arc is created through tkinter.Canvas().Create_arc() through user input().
 from tkinter import*import tkinter    master=tkinter.Tk()def create_arc1():    canvas=tkinter.Canvas(master, width=250, height=300)    canvas.pack()    x1_value=input("Please enter x1 arc value :" )    x1=int(x1_value)    y1_value=input("Please enter y1 arc value :" )    y1=int(y1_value)        x2_value=input("Please enter x1 arc value :" )    x2=int(x2_value)        y2_value=input("Please enter x1 arc value :" )    y2=int(y2_value)    canvas.create_arc(x1, y1, x2, y2)        button=tkinter.Button(master, text="Create Arc",command=create_arc1).pack()master.mainloop() >>> Please enter x1 arc value :50Please enter y1 arc value :110Please enter x1 arc value :150Please enter x1 arc value :250>>> 