Python Problems, programming, java, software, PHP, C programming, programming languages, visual, Pascal, Perl, XML program, UNIX, cyber program, C++, HTML, CSS, Python syntax, software, what is computer, programming, programming languages, computer programming, what is coding, what is programming, contract programming, need a programmer, cyber program, tmbmnadim, Alpha Codist, python, Alpha Codist, blogger, Python problems to solve, pythopn free corse, get python corse for free, Learn Python for free
Integer (int())
An integer is a number that can be written without a fractional component. Here are some examples: 5,9,75,66 and 2048. The word integer means "Whole." Some examples of non-integers are: 5.5 9.3554654.1int() converts any other type to an integer if it is numeric.
Example:
# convert to integer
num = "2048" # This is a string
number = int(num)
print(number)
print(type(num)) #type is to see the type of variables
print(type(number))
Result:
Strings(str())
A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable.This will convert any other type to a string.
Example:
# convert to String
string = str(2048)
print(string)
print(type(string)) #type is to see the type of variables
COMMENTS