Worked Examples · Example 5.13
Q.Example 5.13:
x = 4 #assignment statement
cube = x ** 3 #assignment statement
print (x, cube) #print statement
4 64
x = 4 #assignment statement
cube = x ** 3 #assignment statement
print (x, cube) #print statement
4 64
Yanam CbseNCERTSubjective· 2mImportance★★★★★est
49% · 24/49 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 →Two assignment statements build x = 4 and cube = 4³ = 64; print(x, cube) then displays "4 64" — values separated by print's default single space.
The concept is the anatomy of an assignment statement: Python always evaluates the expression on the right of = first, then binds the resulting object to the name on the left. A statement, unlike an expression typed at the prompt, displays nothing by itself — which is why a print() is needed to see the values.
>>> x = 4 # assignment statement
>>> cube = x ** 3 # assignment statement
>>> print(x, cube) # print statement
4 64
Trace:
| Step | Statement | What happens | x | cube |
|---|---|---|---|---|
| 1 | x = 4 | 4 is bound to the name x | 4 | — |
| 2 | cube = x ** 3 | right side evaluated: 4 ** 3 = 64; result bound to cube | 4 | 64 |
| 3 | print(x, cube) | prints the two values, separated by one space | 4 | 64 |
Output:
4 64
Details worth noting: …
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.