Q.Write the corresponding Python assignment statements:
Five direct assignment statements — including a parallel (tuple) assignment for the three name parts and string concatenation with explicit spaces for the full name.
The idea. Assignment binds a name to a value with =; Python also supports parallel assignment (a, b = 1, 2) and builds strings with the concatenation operator +.
# a) Assign 10 to length and 20 to breadth
length = 10
breadth = 20
# (equivalently: length, breadth = 10, 20)
# b) Average of length and breadth into sum
sum = (length + breadth) / 2 # (10 + 20) / 2 = 15.0
# c) List of strings into stationery
stationery = ['Paper', 'Gel Pen', 'Eraser']
# d) Three strings into first, middle, last (parallel assignment)
first, middle, last = 'Mohandas', 'Karamchand', 'Gandhi'
# e) Concatenated full name with single spaces between the parts
fullname = first + ' ' + middle + ' ' + last
Verification of (e):
>>> fullname
'Mohandas Karamchand Gandhi'
Key points
- (b) needs parentheses:
(length + breadth) / 2. Without them, operator precedence would computelength + (breadth / 2)= 20.0 — the wrong average. Division/always yields a float, sosumis15.0. - (d) parallel assignment unpacks the right-hand tuple left to right — one tidy line instead of three.
- (e) the
' 'literals supply the blank spaces the question asks for;+on strings concatenates.
Naming a variable sum (as the question directs) shadows the built-in function sum() for the rest of the program — fine for this exercise, but avoid it in real code.
a) length = 10 ; breadth = 20 b) sum = (length + breadth) / 2 c) stationery = ['Paper', 'Gel Pen', 'Eraser'] d) first, middle, last = 'Mohandas', 'Karamchand', 'Gandhi' e) fullname = first + ' ' + middle + ' ' + last → 'Mohandas Karamchand Gandhi'.
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.