Question
I need help/clarification with getting the correct output. Change only what is in the curly brackets {} to do what the comment says. Do NOT
I need help/clarification with getting the correct output.
Change only what is in the curly brackets {} to do what the comment says. Do NOT change the parameter list.
For example: # display alpha in a field of width 15, left justified answers[0] = "@{3}@".format(alpha,beta,gamma,delta)
The only part that should be changed is the 3 in the {}.
CODE:
def main(): # create a 12-element list to contain our answers answers = [1]*12 print(answers) #IV1a.
delta = "" alpha = 1234.56789 beta = 268 gamma = "october"
# display alpha in a field of width 15, left justified answers[0] = "@{3}@".format(alpha,beta,gamma,delta)
# display alpha in a field of width 15, centered answers[1] = "@{3}@".format(alpha,beta,gamma,delta)
# display alpha with 20 significant digits answers[2] = "20 sig digs: {3}".format(alpha,beta,gamma,delta)
# display alpha with 4 decimal places answers[3] = "4 dec places: {3}".format(alpha,beta,gamma,delta)
# display both beta and gamma (in that order) # in fields of width 10 that are right justified answers[4] = "@{3}@{3}@".format(alpha,beta,gamma,delta)
# display both gamma and beta (in that order), # in fields of width 5 that are left justified answers[5] = "@{3}@{3}@".format(alpha,beta,gamma,delta)
# display beta in a field of width 9, centered, with all blank # spaces replaced by periodsa # Result should be: ...268...a answers[6] = "{3}".format(alpha,beta,gamma,delta)
# display alpha in a field of width 14, right justified, # with all blank spaces replaced by zeros answers[7] = "{3}".format(alpha,beta,gamma,delta)
# set up the next 4 so that
main()
# A # A # A
(1) the decimal points line up with each other (2) 1 decimal place is shown for answers[8] (3) 4 decimal places are shown for answers[9] (4) 3 decimal places are shown for the final two
# A # # You'll have to play with field widths to line things up.
answers[8] = "{0}".format(528.7568) answers[9] = "{0}".format(-32.17) answers[10] = "{0}".format(1.357908642) answers[11] = "{0}".format(16326.4) ########################################################## # display all the answersa
i=0 for ans in answers:
print("answers[{0}]: {1}".format(i,ans)) i=i+1
def main(): # create a 12-element list to contain our answers answers = [1]*12 print (answers) #IVla. delta - alpha = 1234.56789 beta = 268 gamma = "october" # display alpha in a field of width 15, left justified answers[0] = "@{3}@".format(alpha, beta, gamma, delta) # display alpha in a field of width 15, centered answers[1] = "@{3}@".format(alpha, beta, gamma, delta) # display alpha with 20 significant digits answers[2] = "20 sig digs: {3}".format(alpha, beta, gamma, delta) # display alpha with 4 decimal places answers[3] = "4 dec places: {3}".format(alpha, beta, gamma, delta) # display both beta and gamma (in that order) # in fields of width 10 that are right justified answers[4] = "@{3} @ {3}@".format(alpha, beta, gamma, delta) # display both gamma and beta (in that order), # in fields of width 5 that are left justified answers (5) - "@{3}(3)@".format(alpha, beta, gamma, delta) # display beta in a field of width 9, centered, with all blank # spaces replaced by periods # Result should be: ...268..." answers [6] = "{3}".format(alpha, beta, gamma, delta) # display alpha in a field of width 14, right justified, # with all blank spaces replaced by zeros answers[7] = "{3}".format(alpha, beta, gamma, delta) # set up the next 4 so that # A (1) the decimal points line up with each other (2) 1 decimal place is shown for answers [8] # # (3) 4 decimal places are shown for answers [9] (4) 3 decimal places are shown for the final two # # # You'll have to play with field widths to line things up. ####### answers[8] = "{0}".format(528.7568) answers[9] = "{0}".format(-32.17) answers[10] = "{0}".format(1.357908642) answers[11] = "{0}".format(16326.4) ############################################# # display all the answers" i=0 for ans in answers: print("answers[{0}]: {1}".format(i,ans ) ) i=i+1 main() def main(): # create a 12-element list to contain our answers answers = [1]*12 print (answers) #IVla. delta - alpha = 1234.56789 beta = 268 gamma = "october" # display alpha in a field of width 15, left justified answers[0] = "@{3}@".format(alpha, beta, gamma, delta) # display alpha in a field of width 15, centered answers[1] = "@{3}@".format(alpha, beta, gamma, delta) # display alpha with 20 significant digits answers[2] = "20 sig digs: {3}".format(alpha, beta, gamma, delta) # display alpha with 4 decimal places answers[3] = "4 dec places: {3}".format(alpha, beta, gamma, delta) # display both beta and gamma (in that order) # in fields of width 10 that are right justified answers[4] = "@{3} @ {3}@".format(alpha, beta, gamma, delta) # display both gamma and beta (in that order), # in fields of width 5 that are left justified answers (5) - "@{3}(3)@".format(alpha, beta, gamma, delta) # display beta in a field of width 9, centered, with all blank # spaces replaced by periods # Result should be: ...268..." answers [6] = "{3}".format(alpha, beta, gamma, delta) # display alpha in a field of width 14, right justified, # with all blank spaces replaced by zeros answers[7] = "{3}".format(alpha, beta, gamma, delta) # set up the next 4 so that # A (1) the decimal points line up with each other (2) 1 decimal place is shown for answers [8] # # (3) 4 decimal places are shown for answers [9] (4) 3 decimal places are shown for the final two # # # You'll have to play with field widths to line things up. ####### answers[8] = "{0}".format(528.7568) answers[9] = "{0}".format(-32.17) answers[10] = "{0}".format(1.357908642) answers[11] = "{0}".format(16326.4) ############################################# # display all the answers" i=0 for ans in answers: print("answers[{0}]: {1}".format(i,ans ) ) i=i+1 main()Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started