I wonder you haven't got exceptions. Use
import cgitb; cgitb.enable() at the beginning of your scripts to display them.
After obtaining
b = a['b'],
b is a string, and
range(1, b) will crash. You need to convert it to int first.
range(1, b) is probably not quite what you want.
range(a, b) gives you a list of elemens x[i] such that a <= x[i] < b. That is,
range(1, 4) gives you [1, 2, 3]. You probably want
range(1, b+1).
b = a['b'] is probably not a good idea anyway, as it will crash when you don't supply
b. Rather use
b = a.getfirst('b', '0')
Some servers don't support POST requests (SimpleHTTPD, for ex.) This may lead to
b being missing in sqr.py. You should use GET during development, especially at the beginning. It also makes it easier to test your CGI scripts, as you can pass all parameters in the URL. You can switch to POST later, for production.
Instead of the many print's, use a multiline string - it will make writing long chunks of HTML a lot easier.
The she-bang line should ideally read
#!python to be portable between your local computer and the actual server. (It is not very likely C:\Python26 will be the path to Python everywhere.) When python.exe is on the PATH,
#!python works just fine.
#!python
#index.py
import cgitb; cgitb.enable()
print '''Content-type: text/html\n
<html><head>
<title>My Page</title>
</head><body>
<h1>Powers of two</h1>\n<ol>
<form action="sqr.py" method="post">
<label>How many numbers?</label>
<input type="text" name="b" />
<input type="submit" name="Submit" />
</ol></body></html>'''
#!python
#sqr.py
import cgitb; cgitb.enable()
import cgi
a = cgi.FieldStorage()
b = int( a.getvalue('b', '0') );
print '''\
Content-type: text/html\n
<html><head>
<title>My Page</title>
</head><body>
<h1>Powers of two</h1>\n<ol>'''
for n in range(1,b+1):
print '<li>'+str(2**n)+'</li>'
print '</ol></body></html>'