Python assignment statements Examples

a) Assign 10 to variable length and 20 to variable breadth.
b) Assign the average of values of variables length and breadth to a variable sum.
c) Assign a list containing strings ‘Paper, ‘Gel Pen’, and ‘Eraser’ to variable stationary.
d) Assign the strings ‘Mohandas’, ‘Karamchand ’, and ‘Gandhi’ to variable first, middle and last.
e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to

incorporate blank spaces appropriately between different parts of names.

length = 10
breadth = 20
sum = (length + breadth)/2
stationary = [“paper”, “Gel Pen”, “Eraser”]
first = “Mohandas”  OR first = ‘Mohandas’
Middle = “Karamchand”  OR      middle = ‘Karamchand’
last = “Gandhi”    OR      last = ‘Gandhi’
fullname = first + ‘ ‘ + middle + ‘ ‘ + last

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!