python as pen and paper substitute

Manuel Graune manuel.graune at
Tue Apr 6 17:24:56 EDT 2010

Manuel Graune <manuel.graune at> writes:
> The use-case is acually fairly simple. The point is to use a python
> source-file as subsitute for scrap-paper (with the opportunity to
> edit what is already written and without illegible handwriting).
> The output should  1) show manually selected python code and comments
> (whatever I think is important), 2) show selected results (final and
> intermediate) and 3) *not* show python code that for someone only
> interested in the calculation and the results (and probably not
> knowing python) would just be "noise" (e. g. "import"-statements,
> actual "print()"-functions, etc.). 

Just as an additional example, let's assume I'd want to add the area of
to circles.

The source-file would look something like this:
------>snip   snip<------
#! /usr/bin/python3
from math import pi as PI

d1= 3.0
A1= d1**2 * PI / 4.0
print("Area of Circle 1:\t", A1)

d2= 5.0
A2= d1**2 * PI / 4.0
print("Area of Circle 2:\t", A2)

Sum_Of_Areas= A1 + A2
print("Sum of areas:\t", Sum_Of_Areas)

And the output is:

d1= 3.0
A1= d1**2 * PI / 4.0

Area of Circle 1:        7.06858347058

d2= 5.0
A2= d1**2 * PI / 4.0

Area of Circle 2:        7.06858347058

Sum_Of_Areas= A1 + A2

Sum of areas:    14.1371669412

which can be explained to anyone who knows
basic math and is not at all interested in

> Regards,
> Manuel

A hundred men did the rational thing. The sum of those rational choices was
called panic. Neal Stephenson -- System of the world
Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A  5828 5476 7E92 2DB4 3C99

More information about the Python-list mailing list