Explain the role of repr function.
Answer / chaitanya
Python can convert any value to a string by making use of two functions repr() or str().
The str() function returns representations of values which are human-readable, while repr() generates representations which can be read by the interpreter.
repr() returns a machine-readable representation of values, suitable for an exec command.
Following code sniipets shows working of repr() & str() :
| Is This Answer Correct ? | 0 Yes | 0 No |
How does mro work in python?
What is the output of print str[4: ] if str = ‘ python language’?
Is it better to learn python or java?
What does r before string in python mean?
How to implement an 'enum' in python?
How do you programmatically know the version of python you are using?
What are pandas in python?
What is linspace in python?
Is python object-oriented? What is an object-oriented programming
What do you understand by deque in python?
Is tuple iterable in python?
How to import a module given the full path?