I am trying to learn python and graphing. Could anybody help me with the following?

I want to plot a graph of probabilities using the Binomial which I will write as B(N,n,p); where N is the total number of events, n is the number of successes and p is the probability of a success.

What I want to do is plot the probability of the n events occurring for varying N but fixed n and p.

For example, if n = 20 and p = 0.1, I would like to work out the probability of P(n=20, p=0.1) for N = 20, ... , 100.

Could someone give me the Python code which would allow me to do this?

If it helps, can anybody tell me how to do the following?

(1) Using x in the range 0 to 20, plot y=x^2 and plot the graph.
(2) Is there a library function which will allow me to calculation combiations i.e. nCr values?

To plot the graph I was going to use matplotlib (?)

Essentially all I'm asking is given a function, be it y = x^2, y = sin x + x^3, or whatever and an array of x values e.g. x = -2, -1, 0, 5, 10, how do I plot the graph.

I come from a C++ background, so I assumed that you could have an array of x values e.g. x[5] (for the above) from which I could then calculate the corresponding y values y[5], and then pass these into some kind of plotting routine e.g. matplotlip must have something I suspect.

Well, it depends. I do not know matplotlib. It is likely that it offers mathematical functions including somethin like numpy (that is not part of the standard Python). Python has the math standard module -- see http://docs.python.org/library/math.html and some mathematical functions built into the interpreter. However, it may be much more efficient to use the matplotlib's equivalents. It could also be the case that you prepare x list and the function and the matplotlib computes the results on its own. I do not know. Just generally, the python list type can be used as a heterogeneous dynamic array, zero-based indexing. You can calculate a separate list of y values or a list of tuples with the point coordinates, etc:

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

If it helps, can anybody tell me how to do the following?

(1) Using x in the range 0 to 20, plot y=x^2 and plot the graph.

(2) Is there a library function which will allow me to calculation combiations i.e. nCr values?

Thanks in advance

Issac