Explain the role of repr function.



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

Post New Answer

More Python Interview Questions

What is a 4 tuple?

0 Answers  


What are tokens in python?

0 Answers  


Differentiate between deep and shallow copy in python?

0 Answers  


Why does python use self?

0 Answers  


Explain relational operators in python?

0 Answers  






What are classes in python?

0 Answers  


Explain database connection in python flask?

0 Answers  


How multithreading is achieved in python?

0 Answers  


What does the __ init__ function do in python?

0 Answers  


If you installed a module with pip but it doesn’t import in your idle, what could it possibly be?

0 Answers  


What is raw_input in python 3?

0 Answers  


What is the process to run sub-process with pipes that connect both input and output?

2 Answers  


Categories