Solutions

Solutions#

1. You have been provided with some data in the form of a dictionary:

electronegativities = {'group 1' : (0.98, 0.93, 0.82, 0.82, 0.79, 0.79),
                       'group 2' : (1.57, 1.31, 1.00, 0.95, 0.89, 0.90),
                       'group 3' : (2.04, 1.61, 1.81, 1.78, 1.62),
                       'group 4' : (2.55, 1.90, 2.01, 1.96, 1.87),
                       'group 5' : (3.04, 2.19, 2.18, 2.05, 2.02),
                       'group 6' : (3.44, 2.58, 2.55, 2.10, 2.00)}

a) Calculate the difference between the mean electronegativities of the group \(1\) and group \(2\) elements.

electronegativities = {'group 1' : (0.98, 0.93, 0.82, 0.82, 0.79, 0.79),
                       'group 2' : (1.57, 1.31, 1.00, 0.95, 0.89, 0.90),
                       'group 3' : (2.04, 1.61, 1.81, 1.78, 1.62),
                       'group 4' : (2.55, 1.90, 2.01, 1.96, 1.87),
                       'group 5' : (3.04, 2.19, 2.18, 2.05, 2.02),
                       'group 6' : (3.44, 2.58, 2.55, 2.10, 2.00)}

group_1_mean = sum(electronegativities['group 1']) / len(electronegativities['group 1'])
group_2_mean = sum(electronegativities['group 2']) / len(electronegativities['group 2'])

print(f'The difference in the mean electronegativities is {group_2_mean - group_1_mean}.')
The difference in the mean electronegativities is 0.2483333333333333.

b) Add the electronegativities of the group \(7\) elements to the dictionary under the key 'group 7'. You may store the new electronegativities in a tuple or list.

electronegativities['group 7'] = (3.98, 3.16, 2.96, 2.66, 2.20)

print(electronegativities)
{'group 1': (0.98, 0.93, 0.82, 0.82, 0.79, 0.79), 'group 2': (1.57, 1.31, 1.0, 0.95, 0.89, 0.9), 'group 3': (2.04, 1.61, 1.81, 1.78, 1.62), 'group 4': (2.55, 1.9, 2.01, 1.96, 1.87), 'group 5': (3.04, 2.19, 2.18, 2.05, 2.02), 'group 6': (3.44, 2.58, 2.55, 2.1, 2.0), 'group 7': (3.98, 3.16, 2.96, 2.66, 2.2)}

2. Consider the following blocks of code. Each one of them will cause an error when run. Taking each block one-by-one:

  • Predict which line of code will cause the error and why this line is problematic.

  • Run the block of code in a Jupyter notebook and see whether or not you were correct.

  • Modify the code to solve the problem and thus remove the error.

Block 1:

functional_groups = ('Aldehyde', 'Ketone', 'Ester', 'Ether')

functional_groups.append('Amine')

print(f'Here is a selection of functional groups: {functional_groups}')
functional_groups = ['Aldehyde', 'Ketone', 'Ester', 'Ether']

functional_groups.append('Amine')

print(f'Here is a selection of functional groups: {functional_groups}')
Here is a selection of functional groups: ['Aldehyde', 'Ketone', 'Ester', 'Ether', 'Amine']

Block 2: This code uses the Kapustinskii equation to estimate the lattice energy of NaCl:

\[U_{L} = \frac{kvz_{+}z_{-}}{r_{+} + r_{-}},\]

where \(k\) is a constant, \(v\) is the number of ions in the formula unit, \(z_{+}\) and \(z_{-}\) are the charges of the cations and anions and \(r_{+}\) and \(r_{-}\) are the ionic radii of the cations and anions.

Note

This block also contains a problem which, whilst it will not cause an error, will lead to the wrong result being calculated. See if you can spot and fix this problem in addition to removing the error.

k = 107900 # Constant in the Kapustinskii equation in pm kJmol-1.

group_1_radii = ('90', '116', '152', '166') # Lithium, Sodium, Potassium, Rubidium
group_7_radii = ('119', '167', '182', '206') # Fluorine, Chlorine, Bromine, Iodine

v = 2
z_plus = 1
z_minus = 1

radius_Na = group_1_radii[2]
radius_Cl = group_7_radii[2]

lattice_energy = (k * v * z_plus * z_minus) / (radius_Na + radius_Cl)

print(f'The lattice energy of NaCl is: {lattice_energy} kJmol-1')
k = 107900 # Constant in the Kapustinskii equation in pm kJmol-1.

group_1_radii = (90, 116, 152, 166) # Lithium, Sodium, Potassium, Rubidium
group_7_radii = (119, 167, 182, 206) # Fluorine, Chlorine, Bromine, Iodine

v = 2
z_plus = 1
z_minus = 1

radius_Na = group_1_radii[1]
radius_Cl = group_7_radii[1]

lattice_energy = (k * v * z_plus * z_minus) / (radius_Na + radius_Cl)

print(f'The lattice energy of NaCl is: {lattice_energy} kJmol-1')
The lattice energy of NaCl is: 762.5441696113074 kJmol-1