Question: python a) defining from a literal On one line, define a varible named energy_levels whose value is a list containing the elements {-13.6,-3.4,-1.51,-0.85, -0.54,-0.38,-0.28,-0.21,-0.17} in
python
a) defining from a literal On one line, define a varible named energy_levels whose value is a list containing the elements {-13.6,-3.4,-1.51,-0.85, -0.54,-0.38,-0.28,-0.21,-0.17} in that order. Use list literal notation [...] rather than the list constructor list(...) or other possible approaches. [85]: energy_levels [-13.6,-3.4,-1.51,-0.85,-0.54,-0.38,-0.28,-0.21,-0.17] [86]: # Test code: Execute this immediately after executing your solution cell above it. assert energy_levels [round(-13.6**2, 2) for n in range(1, 10)] b) obtaining the number of elements Write an expression that counts the number of elements in that list and returns the result. [91]: len(energy_levels) [91]: 9 [92]: # Test code: Execute this immediately after executing your solution cell above it. assert _ == 9 c) iterating over c1. Write code that iterates over all elements of the list in energy_levels, in order, printing out "E = xxx eV" for each one, with the value of the element in place of the "xxx". Do NOT use an index variable, the range() function, or access individual list elements with square-bracket subscripting energy_levels[...] Self-check: Verify your output. You should get nine lines, with the last one reading "E = -0.17 eV". c2. Do the same thing again, but this time output each line as "E(nnn) = xxx eV", replacing the "nnn" with "0" for the first element, "1" for the second, etc. Again, do NOT use the range() function or access list elements with energy_levels[...] Instead, use python's enumerate() function (Here is a more friendly tutorial. [ ]: Self-check: Verify your output. The last line should read "E(8) = -0.17 eV". 03. Do the same thing again as in (c2), but this time start counting with 1 instead of O. You could just add 1 to the counter variable every time you print it, but don't do that. Instead, use the enumerate() function's optional start argument
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
