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 python too slow?
What will be the output of data[-2] from the list data = [1,5,8,6,9,3,4]?
Tell me what is dict and list comprehensions are?
Does .net support python?
What applications use python?
What is a modifier in python?
Explain the shortest way to open a text file and display its contents?
What is lambda?
What is the difference between methods & constructors?
How to append to a string in Python?
What is break in python?
python is case sensitive ?