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 is an empty tuple created?
What is docstring in Python?
What is deep copy in python?
Differentiate between split(), sub(), and subn() methods of the re module?
How to add an index, row or column to a pandas dataframe?
Name different types of inheritance in python?
What is the function of negative index?
What is the module and package in python?
How python maintains conditional blocks?
What are special methods in python and how to implement?
Is python strongly typed or weakly typed language?
What are membership operators in python?