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 |
Should I learn c before python?
Why Lambda is used in Python?
Is there any equivalent to scanf() or sscanf()?
What are the differences between the threading and multiprocessing in python?
What is a dictionary in python?
How can we make forms in python?
What is a python method?
Draw a comparison between the range and xrange in python?
Name few python web application frameworks?
Why do lambda forms in python not have the statements?
How to import a module given the full path?
Can I create apps with python?