Answer
Program:
#initialize a and $\mathrm{b}$
$\mathrm{a}=1$
$b=2$
#print table header and first row
$\operatorname{print}\left(\right.$ "a $\left.\mathrm{b} \mathrm{a}^{* *} \mathrm{~b}^{\prime \prime}\right)$
$\operatorname{print}\left(a, "^{\prime \prime}, b, " ", a^{* x} b\right)$
#increment a and $\underline{b}$
$a+=1$
$b+=1$
#print table contents
$\operatorname{print}\left(a, "^{\prime \prime}, b_{n}^{\prime \prime \prime}, a^{* \star} b\right)$
#repeat three more times
$a+=1$
$b+=1$
$\operatorname{print}\left(a, " ", b, " ", a^{* \star} b\right)$
$a+=1$
$b+=1$
$\operatorname{print}\left(a, "^{\prime \prime}, b, " ", a^{* \star} b\right)$
$a+=1$
$b+=1$
$\operatorname{print}\left(a, "^{\prime \prime}, b_{n}^{\prime \prime \prime}, a^{* *} b\right)$
Work Step by Step
Step 1 of 3:
Program Plan:
Create a python file with name 2_12PE.PY. In the file,
- Initialize variable $a$ and $b$ to 1 and 2 respectively.
- Display table header and first row.
- Increment variable a and $b$ by 1
- Display second row of table.
- Repeat the above 2 steps 3 more times.
- Note that this code would have been shorter with for or if loops, but they have not been introduced till chapter 2 , so done in this crude way.
Step 2 of 3:
Program:
#initialize a and $\mathrm{b}$
$\mathrm{a}=1$
$b=2$
#print table header and first row
$\operatorname{print}\left(\right.$ "a $\left.\mathrm{b} \mathrm{a}^{* *} \mathrm{~b}^{\prime \prime}\right)$
$\operatorname{print}\left(a, "^{\prime \prime}, b, " ", a^{* x} b\right)$
#increment a and $\underline{b}$
$a+=1$
$b+=1$
#print table contents
$\operatorname{print}\left(a, "^{\prime \prime}, b_{n}^{\prime \prime \prime}, a^{* \star} b\right)$
#repeat three more times
$a+=1$
$b+=1$
$\operatorname{print}\left(a, " ", b, " ", a^{* \star} b\right)$
$a+=1$
$b+=1$
$\operatorname{print}\left(a, "^{\prime \prime}, b, " ", a^{* \star} b\right)$
$a+=1$
$b+=1$
$\operatorname{print}\left(a, "^{\prime \prime}, b_{n}^{\prime \prime \prime}, a^{* *} b\right)$
Step 3 of 3:
Sample Output:
$a b a^{* *} b$
121
238
3481
451024
5615625