To calculate the number of moles of HCl, we need to use the formula:
```
Moles of HCl = Mass of HCl / Molar mass of HCl
```
The molar mass of HCl is 36.46 g/mol. Therefore, the number of moles of HCl in 31.0 grams is:
```
Moles of HCl = 31.0 g / 36.46 g/mol = 0.850 moles
```
The volume of the solution is 500 cm3, which is equal to 0.5 liters. Therefore, the molarity of the HCl solution is:
```
Molarity = Moles of HCl / Volume of solution (in liters)
```
```
Molarity = 0.850 moles / 0.5 liters = 1.70 M
```
Therefore, the molarity of the HCl solution is 1.70 M.