Write Python statements that print the next formatted output
Write Python statements that print the next formatted outputs using the already as signed variables first, middle, and last: >>> first =\'Marlena\' >>> last = \'Sigel\' >>> middle = \'Mae\' (a) Sigel. Marlena Mae (b) Sigel, Marlena M. (c) Marlena M. Sigel (d) M. M. Sigel
Solution
Python code for printing the next formatted outputs using the already assigned variables
first=\'Marlena\'
middle=\'Mae\'
last=\'Sigel\'
print(\'%s, %s %s\' % (last, middle, first))
print(\'%s, %s %s.\' % (last, first, middle[0]))
print(\'%s %s. %s\' % (first, middle[0], last))
print(\'%s. %s. %s\' % (first[0], middle[0], last))
It is often useful to have more control over the look of your output. Fortunately, Python provides us with an alternative called formatted strings. A formatted string is a template in which words or spaces that will remain constant are combined with placeholders for variables that will be inserted into the string.
