oct() — Python Technical Interview Questions & Answers

oct()

oct()

  • oct() is built into Python. You do not import it. Freshers only need one honest call and the printed result — not a long definition.
  • oct() — output: 0o10. Octal text for 8.
  • Wrong type often raises TypeError. Empty values matter for bool/all/any. Don’t mix oct up with a similar name (sorted vs sort, int vs float).

Technical Interview Tip: Call oct() once and say what prints.

Code Examples for oct()

Example

# oct()
print(oct(8))

oct() — output: 0o10. Octal text for 8.

How to Explain oct() to an Interviewer

Explain oct() as if you are teaching a junior — definition, then one tiny script.

oct() is built-in — no import. One call + exact output.

What does the example print, and why?

oct() — output: 0o10

What mistake do freshers make with oct()?

Wrong type → TypeError.