Explain the role of repr function.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different types of operators in python?

430


Does python have a switch-case statement?

474


How to determine the type of instance and inheritance in python?

498


When should you use generator expressions vs. list comprehensions in Python and viceĀ­versa?

488


How do you clear a python shell?

438






Explain the inheritance in python with an example?

447


Explain delegation in python

455


How do I check if python is installed?

457


How to import a module given the full path?

440


What are the 5 tuples?

458


What does the **kwargs do in python?

473


What is pandas?

473


How do I generate random numbers in python?

475


How do you include a string in python?

453


Explain about python break, continue and pass?

447