Python str
The python str() converts a specified value into a string.
Python str() Function Example
`
str(‘4’)
`
Output:
'4'
Python tuple() Function
The python tuple() function is used to create a tuple object.
Python tuple() Function Example
t1 = tuple()
print('t1=', t1)
# creating a tuple from a list
t2 = tuple([1, 6, 9])
print('t2=', t2)
# creating a tuple from a string
t1 = tuple('Java')
print('t1=',t1)
# creating a tuple from a dictionary
t1 = tuple({4: 'four', 5: 'five'})
print('t1=',t1)
Output:
t1= ()
t2= (1, 6, 9)
t1= ('J', 'a', 'v', 'a')
t1= (4, 5)
Python vars() function
The python vars() function returns the dict attribute of the given object.
Python vars() Function Example
class Python:
def __init__(self, x = 7, y = 9):
self.x = x
self.y = y
InstanceOfPython = Python()
print(vars(InstanceOfPython))
Output:
{'y': 9, 'x': 7}