dc dotCreds
Interview Prep

Python Institute PCAP Interview Questions

Practice real interview prompts based on Python Institute PCAP objectives. Review strong sample answers, listening cues, and common traps before the conversation gets real.

Question 1 of 20

How do `math.ceil()`, `math.floor()`, and `math.trunc()` differ for a negative value, and why is saying they all 'round' insufficient?

Strong Interview Answer

`ceil` moves toward positive infinity, `floor` toward negative infinity, and `trunc` toward zero. For `-3.7`, those results are `-3`, `-4`, and `-3`. The direction matters most when the input is negative.

What to Listen For

  • ceil toward +infinity
  • floor toward -infinity
  • trunc toward zero
  • negative-number behavior

Caution

Listen for the direction of each operation, not vague language such as 'round up' without explaining negative values.