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 |
What is a 4 tuple?
What are tokens in python?
Differentiate between deep and shallow copy in python?
Why does python use self?
Explain relational operators in python?
What are classes in python?
Explain database connection in python flask?
How multithreading is achieved in python?
What does the __ init__ function do in python?
If you installed a module with pip but it doesn’t import in your idle, what could it possibly be?
What is raw_input in python 3?
What is the process to run sub-process with pipes that connect both input and output?