Recently I've been helping out with a community introduction to coding workshop.
Pair programming is a great way to help people improve their programming skills.
By having someone else look over your work you get a chance to have an outside observer help you see new things.
When someone is completely new to programming using pair programming can greatly help them learn.
It is however quite different to pair programming with someone who is more experienced.
What you didn't know you didn't know
One of the biggest benefits of pair programming with a beginner is helping them become aware of useful things that they didn't know they didn't know about.
For example a few years ago I was working with someone in Canada and I saw them type out some really long command line commands.
mv this_is_a_really_long_filename this_directory_is_also_really_long/
I saw them typing this character by character so I said "why aren't you using tab completion?" (https://en.wikipedia.org/wiki/Command-line_completion)
To which they replied "what's that?"
I got them to type the first few characters this_is_a_ then press tab, at which point the rest of the filename appeared on the screen.
I got them to do the same for the directory name.
The were very happy to find out about this, it's not something that they knew about and also isn't the sort of thing that you would know to search for.
Anything that is both useful and hard to search for are the types of situations that pair programming is extremely good for.
One of the biggest things beginners are missing with programming is a mental model of how the code they are writing runs.
Understanding the model of execution is one of the key moments in progression of a programming where they are no longer a complete beginner.
There was a good talk about this at PyCon Australia 2018 called "Running python on your brain computer" https://www.youtube.com/watch?v=3elWlN0MzGw
By showing people how the code will be run exactly you allow a large number of false assumptions and mismatches to be exposed quickly.
Programming is very exacting, the code you write will run exactly as it is written and not "how it should run".
(Incidentally this is part of why it's hard for developers to debug their own work, the focus shift from how things exactly are to how they should be is not an easy one)
A gap between how things actually run and how they are assumed to run causes much frustration for beginners.
Giving people the conceptual tools to understand how the code executes can remove a substantial amount of frustration.
One of my favorite ways to help people get a better sense of how the code runs is to use a visual tool that can execute the code in a step by step manner.
One such tool is called PythonTutor http://pythontutor.com/
You can also use a debugging tool such as GDB or PDB or whatever debugger your language supports to enable step-by-step traversal of the code.