搜尋此網誌

2026年4月23日星期四

Practice in Python

In Python, the expression int(hexNum, 16) means “convert a hexadecimal string into a decimal integer.”

Curly brackets: dictionaries

In Python, def is the keyword used to define a function.

In Python, a for loop is used to repeat a block of code for each item in a sequence (like a list, tuple, string, or range).

for variable in sequence:

    # code block

variable → takes each value from the sequence one by one.

sequence → the collection you want to loop through.

The code block runs once for each item.

In Python, char isn’t a separate data type like in some other languages (for example, C or Java).

def check_number(n):

    if n > 0:

        return "Positive"

    elif n == 0:

        return "Zero"

    else:

        return "Negative"

print(check_number(5))   # Positive

print(check_number(0))   # Zero

print(check_number(-3))  # Negative

In Python, == is the equality operator. It’s used to check whether two values are equal.

print(2 ** 3)   # 8   (2 raised to the power of 3)
print(5 ** 2)   # 25  (5 squared)
print(10 ** 0)  # 1   (any number to the power of 0 is 1)

甚麼是風骨

……風本身是活動的,而且風碰到物,也會使物活動起來︰風吹在樹葉上,樹葉就搖動了;風吹在水上,水面就起波紋了。所以,「風」是一種動力。在具體作品中,「風」就是一種感發的力量,這是我對「風」字的比較現代的解釋……對於人和動物而言,骨是使之能夠站立起來的一種支柱。那甚麼東西使你的作品挺立起來呢?一個是要有非常真切,實在的內容;再一個就是要有很好的組織結構。所以「風骨」就是由內容思想結合了句法、章法而傳達出來的一種感發的力量。我們講詩詞的結構,說它不僅要有平仄這些外表文字的結構,還要有一個情意的結構……

節錄自葉嘉瑩《知人論詩》

2026年4月21日星期二

焦距與景深

焦距越長,景深越淺。即使在相同光圈下,長焦鏡頭的可接受清晰範圍更窄。

拍攝距離

為了保持主體大小一致,使用長焦鏡頭時需要站得更遠。這會改變背景與主體的相對比例,使背景看起來更模糊。

壓縮效果 (Compression Effect)

長焦鏡頭會「壓縮」前景與背景的距離感,背景看似更近、更大,模糊也更顯著。

模糊圈 (Circle of Confusion)

長焦鏡頭在相同構圖下,背景的模糊圈會被放大,因此失焦效果更強烈。

Microsoft Copilot

Longer focal lengths (telephoto lenses) magnify the image more than wide-angle lenses. This magnification also enlarges the blur circles of out-of-focus objects.

Aperture: Changing your f-stop adjusts the angle of the light cone. A smaller aperture (higher f-number) makes the cone narrower, reducing the size of the blur circles and increasing the depth of field.

When your subject is very close to the lens, the light rays entering the camera are highly divergent. Even a tiny movement forward or backward from the focus point causes the light cone to widen rapidly. The Circle of Confusion grows large very quickly, resulting in a shallow depth of field.

For subjects far away, the light rays are more parallel. As you move away from the perfect focus plane, the light cone widens much more slowly.

Google AI mode

Bytes Object in Python

In Python, a bytes object is an immutable sequence of integers in the range 0–255, used to represent raw binary data. It’s similar to a string, but instead of characters, it stores bytes.

Immutable: Once created, it cannot be modified (like str).

When you see a b prefix in Python output, it means the object is a bytes literal — raw binary data rather than a regular string.

UTF-8 is the most widely used character encoding today, representing every Unicode character using 1–4 bytes. It is backward-compatible with ASCII, meaning the first 128 characters (like English letters and digits) are encoded exactly the same as ASCII.

Name: Unicode Transformation Format – 8-bit.

Type: Variable-length encoding (1 to 4 bytes per character).

A bytearray in Python is very similar to a bytes object, but with one key difference: it is mutable. That means you can change its contents after creation, unlike bytes which are immutable.

In Python, string slice notation lets you extract parts of a string (substrings).

Hexadecimal (often shortened to “hex”) is a base-16 numbering system. Instead of using only digits 0–9 like decimal (base-10), it uses 16 symbols:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Compact: Easier to read than long binary strings.

Direct mapping: Each hex digit = exactly 4 bits (a “nibble”).

Common uses: Memory addresses, color codes (#FF0000 = red), encoding binary data, debugging.

# Decimal to hex print(hex(255)) # 0xff # Hex to decimal print(int("ff", 16)) # 255 # Binary ↔ Hex print(bin(0xff)) # 0b11111111 print(hex(0b1010)) # 0xa

x in 0xff

In 0xff, the 0x prefix is Python’s (and many other languages’) way of saying: “this number is written in hexadecimal (base‑16)”.

Microsoft Copilot

《燦爛千陽》最終章

約瑟終將重返迦南,何哀傷之有,

茅舍終將成為玫瑰花園,何哀傷之有,

倘有洪水將至,奪走生靈,

挪亞方舟必將在暴風眼中指引你的方向,何哀傷之有。

Why grieve? For Joseph shall return to Canaan.

Why grieve? For the hut shall become a rose garden.

Though the flood may come and sweep away all life,

the Ark of Noah shall guide you through the storm.

---哈菲茲詩句


出生地:約瑟是雅各與拉結的兒子,出生於迦南地(創世記 30:22–24)。迦南是亞伯拉罕家族的應許之地。

被賣到埃及:因兄弟嫉妒,他被賣為奴隸到埃及(創世記 37:28)。這使他離開了迦南。

在埃及崛起:約瑟憑智慧與解夢能力,成為埃及法老的宰相,掌管糧倉(創世記 41:40–41)。

饑荒與家族遷徙:迦南遭遇饑荒,雅各一家被迫前往埃及求糧。約瑟因此與家人重聚,並安排他們定居在埃及的歌珊地(創世記 47:6)。

歸返的象徵:雖然約瑟死於埃及,但他要求後代將自己的骸骨帶回迦南(創世記 50:25),象徵他最終的歸返。

Microsoft Copilot


卡勒德.胡賽尼《燦爛千陽》

李靜宜譯

Khaled Hosseini "A Thousand Splendid Suns"

controversy

diligence: careful work or great effort

facet: a particular part or aspect of something

temptation: the desire to do or have something that you know is bad or wrong

jeopardize: to risk harming or destroying something/somebody

exonerate: to officially state that somebody is not responsible for something that they have been blamed for

construe: to understand the meaning of a word, a sentence or an action in a particular way

implicit: suggested without being directly expressed

controversy: public discussion and argument about something that many people strongly disagree about, think is bad, or are shocked by

travesty: something that does not have the qualities or values that it should have, and as a result is often considered wrong or offensive

"BG computing" typically refers to background computing (processes running behind the scenes, such as data syncing, indexing, or cloud tasks).

in retrospect: thinking about a past event or situation, often with a different opinion of it from the one you had at the time

grateful: feeling or showing thanks because somebody has done something kind for you or has done as you asked

forge: to move forward in a steady but powerful way

artisan: a person who does work that needs a special skill, making things with their hands

accreditation: official approval given by an organization stating that somebody/something has achieved a required standard

notion: an idea, a belief or an understanding of something

far-fetched: ​very difficult to believe

commonplace: ​done very often, or existing in many places, and therefore not unusual


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2026年4月14日星期二

Strings in Python

In Python, you can concatenate strings using several methods: the + operator for simple joining, join() for efficiency with multiple strings, and formatted approaches like f-strings or format() for readability.

f"My number is: {5}"

F-strings (formatted string literals, introduced in Python 3.6) allow you to embed expressions directly inside a string.

Anything inside {} is evaluated as a Python expression, and its result is converted to a string.

In your case, {5} is just the literal integer 5. Python evaluates it, converts it to "5", and inserts it into the string.

literal: being the most basic meaning of a word or phrase, rather than an extended or poetic meaning

paragraph = """This is a paragraph. It can span multiple lines. No need for explicit newline characters.""" print(paragraph)

Output:

This is a paragraph. It can span multiple lines. No need for explicit newline characters.

In Python, the backslash (\) is an escape character. It signals that the next character has a special meaning or should be treated differently.

\n → newline

the text doesn't stop until it sees \'\'\'

Here, the backslashes are escaping the single quotes so Python doesn’t confuse them with the closing triple quotes. Without the backslashes, Python would think the string ended too early.

Microsoft Copilot