Q. Write the corresponding Python assignment statements:


(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 a variable stationery.

(d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables 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.


Answer:-


(a)
length = 10
breadth = 20

(b)
sum = (length + breadth)/2

(c)
stationery = [‘Paper’, ‘Gel Pen’, ‘Eraser’]

(d)
first = ‘Mohandas’
middle = ‘Karamchand’
last = ‘Gandhi’

We can also assign variable in that way:-

first, middle, last = ‘Mohandas’, ‘Karamchand’, ‘Gandhi’

(e)

fullname = first + ' ' + middle + ' ' + last

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post