Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python typecast

print(str(1))  # convert number to string
print(int("1"))  # convert string to int
print(float(1))  # convert int to float
print(list('hello'))  # convert string to list
print(tuple('hello'))  # convert string to tuple
print(list((1, 2, 3)))  # convert tuple to list
print(tuple([1, 2, 3]))  # convert list to tuple
print(bool(1))  # convert a number to boolean
print(bool(0))  # convert a number to boolean
print(bool(""))  # convert a string to boolean
print(bool("data"))  # convert string to boolean
print(bin(10))  # convert an integer to a binary string
print(hex(10))  # convert an integer to a hex string
print(oct(10))  # convert an integer to an octal string
Comment

typecasting python

a = "1235"
a = int(a)

print(type(a))
print(a + 5)
Comment

how to tyoecast in python

example = 1.3234325
print(type(example))




Comment

PREVIOUS NEXT
Code Example
Python :: Python Pandas: Create new column out of other columns where value is not null 
Python :: Use operator in python list 
Python :: stack python 
Python :: python how to vectorize a function 
Python :: else if 
Python :: python multidimensional dictionary 
Python :: reading from a text file 
Python :: for schleife python 
Python :: string representation of date time 
Python :: python rounding numbers to n digits 
Python :: Python NumPy ravel function Syntax 
Python :: xml to python list in python 
Python :: python loop until condition met 
Python :: variable referenced before assignment python 
Python :: subtract from dataframe 
Python :: python new 
Python :: python iterator 
Python :: dfs 
Python :: string pythhon 
Python :: how to check if variable in python is of what kind 
Python :: python string: .title() 
Python :: pass in python 
Python :: python get file size 
Python :: what is thread in python 
Python :: sorting in python 
Python :: indefinite loops python 
Python :: buble short 
Python :: pd sample every class 
Python :: imagefont cannot open resource 
Python :: python sort list by length of sublist 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =