Re: Using Python as a Calculator

Jorge Garcia via Edu-sig <[email protected]> Sun, 22 Jun 2025 14:32:14 -0400
Newsgroups gmane.comp.python.education
Message-ID <CAPkJXS15=LOTSAGTA8r4jkdhBGoQq_wvCeBzv-Qm+O+gGkrsVQ@mail.gmail.com>
--===============0074221345332944844==
Content-Type: multipart/alternative; boundary="0000000000001f763706382d511f"

--0000000000001f763706382d511f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I use sympy all the time in my Multivariate Calculus class!

On Sun, Jun 22, 2025, 2:30=E2=80=AFPM Jorge Garcia <[email protected]> wro=
te:

> Beautiful, no?
>
> On Sun, Jun 22, 2025, 2:17=E2=80=AFPM Jorge Garcia <[email protected]> w=
rote:
>
>> https://colab.research.google.com/drive/1Gbc1TbCr6FabIWkr_HnCu7R2x1FcLnH=
z
>>
>> On Sun, Jun 22, 2025, 2:12=E2=80=AFPM Jorge Garcia <[email protected]> =
wrote:
>>
>>> Share code on github is all well and good, but sharing in a Jupyter
>>> Notebook such as colab.research.google.com makes it executable in your
>>> browser right away!
>>>
>>> On Sun, Jun 22, 2025, 2:01=E2=80=AFPM Wes Turner via Edu-sig <edu-sig@p=
ython.org>
>>> wrote:
>>>
>>>> Here's the link to that PR, which makes things testable and then
>>>> verifies with test assertions:
>>>>
>>>> https://github.com/4dsolutions/python_camp/pull/4
>>>>
>>>> ... @staticmethod is for when you want to add a method on a class that
>>>> doesn't take self as the first parameter.
>>>>
>>>> On Sun, Jun 22, 2025, 1:52=E2=80=AFPM Wes Turner <[email protected]=
> wrote:
>>>>
>>>>> How to best phase in Python?
>>>>>
>>>>> It can check your answers every time something is changed:
>>>>>
>>>>> ```py
>>>>> 1+1
>>>>>
>>>>> print(1+1)
>>>>>
>>>>> x =3D 1 +1
>>>>> print(x)
>>>>>
>>>>> 1+1 =3D=3D True
>>>>>
>>>>> print(1+1 =3D=3D True)
>>>>>
>>>>> assert 1+1 =3D=3D True
>>>>> print("It did not raise AssertionError")
>>>>>
>>>>> assert 1+1 =3D=3D False
>>>>> print("This won't run, because AssertionError is an Exception, and
>>>>> control flow is interrupted on Exception")
>>>>>
>>>>>
>>>>> # %%
>>>>> import unittest
>>>>> test =3D unittest.TestCase()
>>>>>
>>>>> test.assertEqual(1+1, 0)
>>>>> ```
>>>>>
>>>>> We verify our assumptions about types and values of parameters and
>>>>> return values at runtime; we check preconditions and post conditions.
>>>>>
>>>>> I am reminded of camper_program.py from 2020:
>>>>>
>>>>> https://mail.python.org/archives/list/[email protected]/message/OYZ2=
QPDYDFRV2PPJXEOHUTFWFPZVOCJO/
>>>>>
>>>>> Maybe a good prompt to lock in that automated testing is much more
>>>>> efficient than attempting to manually test everything after every cha=
nge:
>>>>>
>>>>> "Write your own test assertion library; starting with `def
>>>>> assertEqual(a, b, msg)`"
>>>>>
>>>>> On Sun, Jun 22, 2025, 1:19=E2=80=AFPM kirby urner via Edu-sig <
>>>>> [email protected]> wrote:
>>>>>
>>>>>>
>>>>>> From an educator's perspective, how to best phase-in Python is often
>>>>>> a core question.
>>>>>>
>>>>>> One answer is: use it the same way you might use a calculator in the
>>>>>> classroom, but show off why it's better.
>>>>>>
>>>>>> An example (new today) of what I share with my student and peer
>>>>>> faculty, perhaps new to Python:
>>>>>>
>>>>>>
>>>>>> https://github.com/4dsolutions/School_of_Tomorrow/blob/master/smod_p=
lay.py
>>>>>>
>>>>>> A mix of Python + geometric content already familiar to those using
>>>>>> my curriculum.
>>>>>>
>>>>>> The docstring itself contains a link to the famous Using Python as a
>>>>>> Calculator tutorial at the Python dot org site.
>>>>>>
>>>>>> Kirby
>>>>>>
>>>>>> _______________________________________________
>>>>>> Edu-sig mailing list -- [email protected]
>>>>>> To unsubscribe send an email to [email protected]
>>>>>> https://mail.python.org/mailman3//lists/edu-sig.python.org
>>>>>> Member address: [email protected]
>>>>>>
>>>>> _______________________________________________
>>>> Edu-sig mailing list -- [email protected]
>>>> To unsubscribe send an email to [email protected]
>>>> https://mail.python.org/mailman3//lists/edu-sig.python.org
>>>> Member address: [email protected]
>>>>
>>>

--0000000000001f763706382d511f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">I use sympy all the time in my Multivariate Calculus class!<=
/p>
<br><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=
=3D"gmail_attr">On Sun, Jun 22, 2025, 2:30=E2=80=AFPM Jorge Garcia &lt;<a h=
ref=3D"mailto:[email protected]">[email protected]</a>&gt; wrote:<br></di=
v><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex"><p dir=3D"ltr">Beautiful, no?</p>
<br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sun=
, Jun 22, 2025, 2:17=E2=80=AFPM Jorge Garcia &lt;<a href=3D"mailto:calcpage=
@gmail.com" target=3D"_blank" rel=3D"noreferrer">[email protected]</a>&gt;=
 wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><p dir=3D"ltr"><a href=3D"h=
ttps://colab.research.google.com/drive/1Gbc1TbCr6FabIWkr_HnCu7R2x1FcLnHz" r=
el=3D"noreferrer noreferrer" target=3D"_blank">https://colab.research.googl=
e.com/drive/1Gbc1TbCr6FabIWkr_HnCu7R2x1FcLnHz</a></p>
<br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sun=
, Jun 22, 2025, 2:12=E2=80=AFPM Jorge Garcia &lt;<a href=3D"mailto:calcpage=
@gmail.com" rel=3D"noreferrer noreferrer" target=3D"_blank">calcpage@gmail.=
com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir=3D"ltr">S=
hare code on github is all well and good, but sharing in a Jupyter Notebook=
 such as <a href=3D"http://colab.research.google.com" rel=3D"noreferrer nor=
eferrer noreferrer" target=3D"_blank">colab.research.google.com</a> makes i=
t executable in your browser right away!</p>
<br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sun=
, Jun 22, 2025, 2:01=E2=80=AFPM Wes Turner via Edu-sig &lt;<a href=3D"mailt=
o:[email protected]" rel=3D"noreferrer noreferrer noreferrer" target=3D"_b=
lank">[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"auto">Here&#39;s the link to that PR, which makes things t=
estable and then verifies with test assertions:<div dir=3D"auto"><br></div>=
<div dir=3D"auto"><a href=3D"https://github.com/4dsolutions/python_camp/pul=
l/4" rel=3D"noreferrer noreferrer noreferrer noreferrer noreferrer" target=
=3D"_blank">https://github.com/4dsolutions/python_camp/pull/4</a></div><div=
 dir=3D"auto"><br></div><div dir=3D"auto">... @staticmethod is for when you=
 want to add a method on a class that doesn&#39;t take self as the first pa=
rameter.=C2=A0</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" c=
lass=3D"gmail_attr">On Sun, Jun 22, 2025, 1:52=E2=80=AFPM Wes Turner &lt;<a=
 href=3D"mailto:[email protected]" rel=3D"noreferrer noreferrer noreferr=
er noreferrer noreferrer" target=3D"_blank">[email protected]</a>&gt; wr=
ote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D=
"auto"><div dir=3D"auto">How to best phase in Python?</div><div dir=3D"auto=
"><br></div><div dir=3D"auto">It can check your answers every time somethin=
g is changed:</div><div dir=3D"auto"><br></div><div dir=3D"auto">```py</div=
><div dir=3D"auto">1+1</div><div dir=3D"auto"><br></div><div dir=3D"auto">p=
rint(1+1)</div><div dir=3D"auto"><br></div><div dir=3D"auto">x =3D 1 +1</di=
v><div dir=3D"auto">print(x)</div><div dir=3D"auto"><br></div><div dir=3D"a=
uto">1+1 =3D=3D True</div><div dir=3D"auto"><br></div><div dir=3D"auto">pri=
nt(1+1 =3D=3D True)</div><div dir=3D"auto"><br></div><div dir=3D"auto">asse=
rt 1+1 =3D=3D True</div><div dir=3D"auto">print(&quot;It did not raise Asse=
rtionError&quot;)</div><div dir=3D"auto"><br></div><div dir=3D"auto">assert=
 1+1 =3D=3D False</div><div dir=3D"auto">print(&quot;This won&#39;t run, be=
cause AssertionError is an Exception, and control flow is interrupted on Ex=
ception&quot;)</div><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div=
><div dir=3D"auto"># %%</div><div dir=3D"auto">import unittest</div><div di=
r=3D"auto">test =3D unittest.TestCase()</div><div dir=3D"auto"><br></div><d=
iv dir=3D"auto">test.assertEqual(1+1, 0)</div><div dir=3D"auto">```</div><d=
iv dir=3D"auto"><br></div><div dir=3D"auto">We verify our assumptions about=
 types and values of parameters and return values at runtime; we check prec=
onditions and post conditions.</div><div dir=3D"auto"><br></div><div dir=3D=
"auto">I am reminded of camper_program.py from 2020:=C2=A0</div><a href=3D"=
https://mail.python.org/archives/list/[email protected]/message/OYZ2QPDYDF=
RV2PPJXEOHUTFWFPZVOCJO/" rel=3D"noreferrer noreferrer noreferrer noreferrer=
 noreferrer noreferrer" target=3D"_blank">https://mail.python.org/archives/=
list/[email protected]/message/OYZ2QPDYDFRV2PPJXEOHUTFWFPZVOCJO/</a><div d=
ir=3D"auto"><br></div><div dir=3D"auto">Maybe a good prompt to lock in that=
 automated testing is much more efficient than attempting to manually test =
everything after every change:</div><div dir=3D"auto"><br></div><div dir=3D=
"auto">&quot;Write your own test assertion library; starting with `def asse=
rtEqual(a, b, msg)`&quot;<br><br><div class=3D"gmail_quote" dir=3D"auto"><d=
iv dir=3D"ltr" class=3D"gmail_attr">On Sun, Jun 22, 2025, 1:19=E2=80=AFPM k=
irby urner via Edu-sig &lt;<a href=3D"mailto:[email protected]" rel=3D"nor=
eferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target=3D"_=
blank">[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmai=
l_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,20=
4,204);padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_default" styl=
e=3D"font-family:verdana,sans-serif;font-size:small"><br></div><div class=
=3D"gmail_default" style=3D"font-family:verdana,sans-serif;font-size:small"=
>From an educator&#39;s perspective, how to best phase-in Python is often a=
 core question.=C2=A0</div><div class=3D"gmail_default" style=3D"font-famil=
y:verdana,sans-serif;font-size:small"><br></div><div class=3D"gmail_default=
" style=3D"font-family:verdana,sans-serif;font-size:small">One answer is: u=
se it the same way you might use a calculator in the classroom, but show of=
f why it&#39;s better.</div><div class=3D"gmail_default" style=3D"font-fami=
ly:verdana,sans-serif;font-size:small"><br></div><div class=3D"gmail_defaul=
t" style=3D"font-family:verdana,sans-serif;font-size:small">An example (new=
 today) of what I share with my student and peer faculty, perhaps new to Py=
thon:</div><div class=3D"gmail_default" style=3D"font-family:verdana,sans-s=
erif;font-size:small"><br></div><div class=3D"gmail_default" style=3D"font-=
family:verdana,sans-serif;font-size:small"><a href=3D"https://github.com/4d=
solutions/School_of_Tomorrow/blob/master/smod_play.py" rel=3D"noreferrer no=
referrer noreferrer noreferrer noreferrer noreferrer noreferrer" target=3D"=
_blank">https://github.com/4dsolutions/School_of_Tomorrow/blob/master/smod_=
play.py</a></div><div class=3D"gmail_default" style=3D"font-family:verdana,=
sans-serif;font-size:small"><br></div><div class=3D"gmail_default" style=3D=
"font-family:verdana,sans-serif;font-size:small">A mix of Python=C2=A0+ geo=
metric content already familiar to those using my curriculum.</div><div cla=
ss=3D"gmail_default" style=3D"font-family:verdana,sans-serif;font-size:smal=
l"><br></div><div class=3D"gmail_default" style=3D"font-family:verdana,sans=
-serif;font-size:small">The docstring itself contains a link to the famous =
Using Python as a Calculator tutorial at the Python dot org site.</div><div=
 class=3D"gmail_default" style=3D"font-family:verdana,sans-serif;font-size:=
small"><br></div><div class=3D"gmail_default" style=3D"font-family:verdana,=
sans-serif;font-size:small">Kirby</div><div class=3D"gmail_default" style=
=3D"font-family:verdana,sans-serif;font-size:small"><br></div></div>
_______________________________________________<br>
Edu-sig mailing list -- <a href=3D"mailto:[email protected]" rel=3D"norefe=
rrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" tar=
get=3D"_blank">[email protected]</a><br>
To unsubscribe send an email to <a href=3D"mailto:[email protected]"=
 rel=3D"noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer n=
oreferrer" target=3D"_blank">[email protected]</a><br>
<a href=3D"https://mail.python.org/mailman3//lists/edu-sig.python.org" rel=
=3D"noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noref=
errer noreferrer" target=3D"_blank">https://mail.python.org/mailman3//lists=
/edu-sig.python.org</a><br>
Member address: <a href=3D"mailto:[email protected]" rel=3D"noreferrer n=
oreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target=3D=
"_blank">[email protected]</a><br>
</blockquote></div></div></div>
</blockquote></div>
_______________________________________________<br>
Edu-sig mailing list -- <a href=3D"mailto:[email protected]" rel=3D"norefe=
rrer noreferrer noreferrer noreferrer" target=3D"_blank">[email protected]=
</a><br>
To unsubscribe send an email to <a href=3D"mailto:[email protected]"=
 rel=3D"noreferrer noreferrer noreferrer noreferrer" target=3D"_blank">edu-=
[email protected]</a><br>
<a href=3D"https://mail.python.org/mailman3//lists/edu-sig.python.org" rel=
=3D"noreferrer noreferrer noreferrer noreferrer noreferrer" target=3D"_blan=
k">https://mail.python.org/mailman3//lists/edu-sig.python.org</a><br>
Member address: <a href=3D"mailto:[email protected]" rel=3D"noreferrer nor=
eferrer noreferrer noreferrer" target=3D"_blank">[email protected]</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>

--0000000000001f763706382d511f--

--===============0074221345332944844==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Edu-sig mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/edu-sig.python.org
Member address: [email protected]

--===============0074221345332944844==--