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 |
Is self mandatory in python?
How do I find out the Python version in CMD?
Is python completely free?
How do you sort in python?
What is python shell and idle?
Does python have oops concepts?
What is the difference between if and elif in python?
Explain “with” statement in python?
Does python have overloading?
Is python faster than python2?
How is print statement represented in python 3 (v/s python2)?
Is r similar to python?