I was trying to open the lock to use the bike, the key was jammed and I forced it so much it snapped so now part of the key is inside the lock and consequently the bike is locked and the whole lock is impossible to remove. What is the best procedure to follow?
If this is the cable or chain lock use bolt cutter. If it's a D-lock (U-lock) you have to use a hacksaw.
If part of the key is in the lock, your best bet is to save the key stub and use it to turn the lock. The trick is to get the broken off piece in the right position – not too far out and not too far in – and turn it. It'll work like a regular key, and I've opened a few locks with broken off keys this way. Instead of the stub, a screwdriver might also do the trick.
If the lock mechanism is rusty, try spraying some WD-40 on it and let it sit overnight. If it's very rusty, repeat the exercise one more time.
If you pushed the broken off piece in too far, it will not turn. In that case, you could try with a dab of super glue on the key stub, press it onto the fragment, let it harden and pull it out a bit.