Molarity is defined as the moles of a solute per liters of a solution.
pH is a figure expressing the acidity or alkalinity of a solution on a logarithmic scale on which 7 is neutral, lower values are more acid and higher values more alkaline.
Formula to calculate pH from molarity.
To calculate the pH of an aqueous solution you need to know the concentration of the hydronium ion in moles per liter (molarity).

Example:
Find the pH of a 0.0020 M HCl solution.
Since we know that HCl is a strong acid and is 100% ionized in water, therefore;

Thus, the pH of the acid is 2.7.