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 |
Why everything in python is an object?
What is the difference between deep and shallow copy?
What are the basic datatypes in python?
What is metadata in python?
How to make a chain of function decorators?
What is the print in python?
What are the other languages that support strongly for regular expressions?
How many basic types of functions are available in python?
Is python good for microservices?
How many types of loops are there in python?
Why do we need break and continue in python?
What does __ name __ mean in python?