Essential Python 3
Stephen Lukacs (2) iquanta.org/instruct/python
python f-string formatting of basic arithmetic ::: a = 11, b = -14, c = 7, d = 99, e = 103, f1pi = 6.2832, or raw calculation = 14.
"""
reference: https://iquanta.org/instruct/python ::: Example 0, Essential Python 3 ::: Stephen Lukacs, Ph.D. ©2021-11-15
multi-line comment delimited between 3 single- or double-quotes, and they have to match on both ends.
all programming languages have different "structures". the most basic structures are numbers and strings. numbers
are subdivided into decimal or floating point numbers, like measurements, in python called "float", and integers or
counting numbers, in python called "int". strings are any line or stream of alphanumeric characters, in python,
surrounded by either single- or double-quotes.
variables are also in all programming languages. variables are simply a named storage area and they store any
structure assigned to that stored variable name. below the variables, a, b, c, d, e, and f1pi all store numbers.
a, b, c, d, and e store int, and f1pi stores a float because pi is a decimal number.
at its heart, python is a math language. entering python, you can use it as a calculator...
"""
#single-line comment begins with a #
from math import pi
a = 7 + 4
b = -3 - 11
c = -3 - (-10)
d = (2**2 * 3 * 7) + 15 #in-line comment
e = a + b + c + d
f1pi = 2*pi
"""
executing only the above doesn't make it very human readable. in fact, python will return a dict structure. more
on those later. if you want to see the raw output, then comment the following line with a # character. instead,
we can gracefully format it using the python f-strings with single- or double-quotes proceeded by the "f" character,
as below...
"""
rtn = f"python f-string formatting of basic arithmetic ::: a = {a}, b = {b}, c = {c}, d = {d}, e = {e}, f1pi = {f1pi:.4f}, or raw calculation = {a - 6 + 3**2}."
"""
where single curly brackets, { and }, delimit a calculation to evaluate and return the result, the ":.4f" formats the
output to the f-string, which there are many many f-string formattings, and "rtn" is a reserved word of this server
that returns whatever is passed to rtn.
"""