Let me start with an example:
There is a c++ program which can be run on my server, the program is named "Guess the Number" which means every time it runs,  

first it will generate an integer between 1 and 100 randomly.
then i need the user to guess a number and pass it to me though a web page, form or something. 
now i want pass the number to the program and then the program will tell me whether it's bigger or smaller. 
then i put the information on the web page to let the user know and then make his next guess.

i am able to write the program. and i know how pass the first argument and give back the information, but don't know how to interact in the next steps. i.e.  
How to pass the arguments to the program REAL-TIME and get the output?
to make this more clearly:

i use subprocess in python to run the program with the first argument and get the output.
the c++ program use std inputs and outputs, like while (!check(x)) scanf("%d",&x);, and in check(int x), i use if (x>rand_num) printf("too big\n"); to output.
This sounds a lot like a homework question, but even with this list, you have a lot of work ahead of you for a dubious reward, so here we go.

Your C++ program should listen on a socket
Your python program needs to listen on a web socket, and also have a connection open to the C++ program through the C++ socket. 
I'd suggest something like web.py for your web framework
Your web.py program is going to accept XMLHTTP Requests at a URL
your web page is going to submit requests through that XMLHTTP request, and send results back into the web page.

An easy way to do this on the frontend is to you jquery ajax commands; they will hit your web.py URL, which will validate the input, call a function to send it off to the C++ socket, get a response and send it back as a response to your jquery request.
Good luck.
How to INTERACT between a program on the server and the user via a web page REAL-TIME