Synoptic Exercises

Synoptic Exercises#

Okay folks, time to get loopy.

1. Write a program to play “Fizz Buzz”. Your code should loop over numbers between \(1\) and \(100\), printing 'Fizz' for those that are divisible by \(3\), 'Buzz' for those divisible by \(5\) and 'Fizz Buzz' for those divisible by both \(3\) and \(5\).

2. You have been provided with the melting and boiling points of various metals:

metals = ['Fe', 'Al', 'Hg', 'Ti', 'Pb']
melting_points = [1811, 933, 234, 1941, 601]
boiling_points = [3134, 2743, 630, 3560, 2022]

Using a for loop, determine whether each metal is a solid, liquid or gas at \(500\,\mathrm{K}\).

Tip

Remember you can use the enumerate function to keep track of which iteration you are on in a loop.

3. Consider \(5.00 \times 10^{-2}\,\mathrm{mol}\) of an ideal gas in a \(1.00 \times 10^{-3}\,\mathrm{m}^{3}\) container.

Calculate the pressure at each temperature between \(100\,\mathrm{K}\) and \(1000\,\mathrm{K}\) in steps of \(50\,\mathrm{K}\) and append these values to a list.

Reminder

You can access the gas constant \(R\) by importing scipy.

4. Recall the previous exercise in lab 1 in which we calculated various lines in the Hydrogen emission spectrum using the following equation:

\[\frac{1}{\lambda} = R_{\mathrm{H}}\left[\frac{1}{n_{1}^{2}} - \frac{1}{n_{2}^{2}}\right],\]

where \(\lambda\) is the wavelength, \(R_{\mathrm{H}}\) is the Rydberg constant, \(n_{1}\) is the principal quantum number of the emission state and \(n_{2}\) is the principal quantum number of the excited state.

a) Write a for loop to print the wavelengths (in nanometres) of the first \(10\) lines of the Balmer series (\(n_{1} = 2\)).

b) Add one additional loop to your code so that it can print the wavelengths of the first \(10\) lines in the Lyman, Balmer and Paschen series.

c) Create three empty lists called lyman, balmer and paschen.

Add some logic to your code from b) so that, rather than printing each wavelength to the screen, each value is stored in the appropriate list.