In str type conversion, we use the built-in funtion str() to convert variables of other types to a string type. This function returns the string type of object (value).
Casting int to str type
num = 11
print(type(num)) # class 'int'
# convert int to str type
s1 = str(num)
print(s1) # Output '11'
print(type(s1)) # Output class 'str'
Casting float type to str type
num = 11.58
print(type(num)) # class 'float'
# convert float to str type
s1 = str(num)
print(s1) # Output '11.58'
print(type(sl)) # Output class 'str'
Casting complex type to str type
complex_num = 11 + 2j
print(type(complex_num)) # class 'complex'
# convert complex to str type
s1 = str(complex_num)
print(s1) # Output '(11+2j)'
print(type(s1)) # class 'str'
Casting bool type to str type
b1 = True
b2 = False
print(type(b1)) # class 'bool'
# convert bool to str type
s1 = str(b1)
s2 = str(b2)
print(s1) # Output 'True'
print(s2) # Output 'False'
print(type(s1)) # class 'str'