r/learnpython 2d ago

Practice Problems Math in Python

Hi,

I am currently trying to learn the relevant Python parts as a chemistry student. I think I know the basic parts (varibals/lists etc.) and I am searching for some practice problems where I can try some calculations, functions and plots with mathplotlib. Do you guys have a set of task where I can train/learn with?

Thank you very much for your help!

Limic

3 Upvotes

5 comments sorted by

2

u/Plenty-Midnight2075 2d ago

Since you’re studying chemistry, I’d honestly skip generic coding exercises and practice with problems that look like things you might actually use.

A nice progression could be:

  1. Radioactive decay - calculate N(t)=N0e−λtN(t)=N_0e^{-\lambda t} and plot concentration vs time.
  2. Beer–Lambert law - calculate absorbance for different concentrations and plot a calibration curve.
  3. Reaction kinetics - simulate zero/first/second-order reactions and compare the curves.
  4. Experimental data - load concentration/absorbance data from a CSV, calculate mean/std, and plot it with error bars.
  5. Curve fitting - generate some noisy experimental data and fit a line or exponential curve to it.
  6. Titration curve - calculate pH as titrant is added and plot pH vs volume.

For each one, try making a function first, then generate a range of values with NumPy, and finally plot the result with Matplotlib.

That’ll teach you functions, loops/arrays, NumPy and plotting while also building intuition for stuff you’ll actually encounter in chemistry. Much more useful IMO than solving 50 “reverse this string” exercises.

1

u/Ilastria 2d ago

Concerning math / computational problems „Problem Euler“ is a good source with over 1000 problems.

1

u/nog642 2d ago

You mean Project Euler

1

u/Ilastria 1d ago

oh yeah lol typo.

1

u/thisisappropriate 2d ago

You could grab some real world data to play with https://www.tableau.com/en-gb/learn/articles/free-public-data-sets the google example lets you download CSVs of data from their charts so you can even see what your chart should look like and some have APIs if you want to include getting APIs in your learning.