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 |
How useful is python?
How are phon blocks defined?
What are the packages?
What are the ideal naming conventions in python?
Why python is called portable?
How to check the string consists of alphanumeric characters ?
Does python support multiple inheritance?
How do you execute a python script?
What is the use of repr function in python?
What does * args mean in python?
How to convert a string to lowercase in Python?
Can we use break in if statement in python?