This Python repr() Quiz helps you master how to get a printable and unambiguous string representation of objects. Learn the differences between repr() and str(), and how repr() is used in debugging, logging, and serialization.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
What is the purpose of the repr() function in Python?
Correct
Incorrect
Question 2 of 15
2. Question
What will be the output of repr(“Hello”)?
Correct
Incorrect
Question 3 of 15
3. Question
What does the repr() function return for integers?
Correct
Incorrect
Question 4 of 15
4. Question
What will this code print?
x = ‘DataFlair’ print(repr(x))
Correct
Incorrect
Question 5 of 15
5. Question
Which of the following is true about repr() vs str()?
Correct
Incorrect
Question 6 of 15
6. Question
What does repr(3.14) return?
Correct
Incorrect
Question 7 of 15
7. Question
What is the output of this code?
print(repr(‘It\’s fine’))
Correct
Incorrect
Question 8 of 15
8. Question
Which method inside a class controls what repr() returns?
Correct
Incorrect
Question 9 of 15
9. Question
What will the output be?
print(repr([1, 2, 3]))
Correct
Incorrect
Question 10 of 15
10. Question
Can eval(repr(x)) == x be True?
Correct
Incorrect
Question 11 of 15
11. Question
What does this code output?
s = “Line1\nLine2” print(repr(s))
Correct
Incorrect
Question 12 of 15
12. Question
What is the output of type(repr(123))?
Correct
Incorrect
Question 13 of 15
13. Question
What does this class return?
class Test: def __repr__(self): return “Test()”
print(repr(Test()))
Correct
Incorrect
Question 14 of 15
14. Question
What’s the purpose of using repr() in debugging?
Correct
Incorrect
Question 15 of 15
15. Question
Which of the following can be passed to repr()?
Correct
Incorrect
Summary
These MCQs on Python repr() function help you understand how to obtain the unambiguous, developer-friendly string representation of objects — essential for logging, debugging, and object introspection.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.