Worked Examples · Example 7.6
Q.Example 7.6:
from math import ceil,sqrt
value = ceil(624.7)
sqrt(value)
from math import ceil,sqrt
value = ceil(624.7)
sqrt(value)
Uttar Pradesh UpmspTextbookSubjective· 2mImportance★★★★★est
20% · 8/40 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Example 7.6 imports two functions at once (from math import ceil,sqrt); ceil(624.7) rounds up to 625, and sqrt(625) evaluates to 25.0.
The idea. The from module import name1, name2 form can pull in several attributes in one statement — here ceil (smallest integer >= x) and sqrt (square root) from the math module, both then callable without the math. prefix.
>>> from math import ceil,sqrt
>>> value = ceil(624.7)
>>> sqrt(value)
25.0
Step-by-step trace
| Step | Expression | Result | Why |
|---|---|---|---|
| 1 | ceil(624.7) | 625 | ceiling = smallest integer not less than 624.7 |
| 2 | value = 625 | — | assignment; nothing displayed |
| 3 | sqrt(value) = sqrt(625) | 25.0 | 25 × 25 = 625; math.sqrt always returns a float |
Expected output — only the last expression echoes in the interactive shell:
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.