Some observations and suggestions:
- It's always a good practice to stick to conventions laid out in PEP8 - Function and Variable Names
- I know that in homework it's not always the case but in real life one should always try to generalise or abstract as much as possible. One way of doing it:
- It's always a good practice to stick to conventions laid out in PEP8 - Function and Variable Names
- I know that in homework it's not always the case but in real life one should always try to generalise or abstract as much as possible. One way of doing it:
def convert_temperature(temperature, base='Celsius'): bases = ['Celsius', 'Fahrenheit'] if base.title() not in bases: raise ValueError(f'Conversion base must one of values: {", ".join(bases)}') conversions = {'Celsius': lambda t: (t - 32) / 1.8, 'Fahrenheit': lambda t: (t * 1.8) + 32} return conversions[base](temperature)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.