Adventures in
Python: Printing Mathematical Symbols with
Unicodes
Got to start somewhere.
I confess that I am a beginner when it comes to Python.
With the use of the backslash, followed by a u, then four hexadecimal numbers, Python
can print all sorts of symbols not easily found on a standard keyboard. Some common math symbols and their Unicode:
039A
|
Δ
|
03C0
|
π
|
2202
|
∂
|
2248
|
≈
|
03A3
|
Σ
|
00B0
|
°
|
221A
|
√
|
2260
|
≠
|
03A6
|
ϕ
|
0283
|
∫
|
2264
|
≤
|
221E
|
∞
|
03C3
|
μ
|
03B4
|
δ
|
2265
|
≥
|
03B8
|
θ
|
03BB
|
λ
|
2220
|
∠
|
03B1
|
α
|
03B2
|
β
|
03C3
|
σ
|
0413
|
Γ
|
2205
|
∅
|
29A8
|
⦨
|
2282
|
⊂
|
2283
|
⊃
|
221B
|
∛
|
221D
|
∝
|
A short program that demonstrates calling the Unicode characters:
# Program 001:
Python Program
# Unicode is the
format \uxxxx
# print command is
used
print("This is
some of my favorite constants (to 8 places).")
print("\u221A
\u2248 1.41421356")
print("\u03C0
\u2248 3.14159265")
print("e \u2248
2.71828183")
print("\u03A6
\u2248 1.61803399")
Anything that comes after the hashtag (#) is a comment.
Output:
This is some of my
favorite constants (to 8 places).
√ ≈ 1.41421356
π ≈ 3.14159265
e ≈ 2.71828183
Φ ≈ 1.61803399
>>>
Fairly simple. Next
up, I learn about input and the type of objects (the hard way).
Eddie
This blog is property of Edward Shore, 2017.