搜尋此網誌

2026年4月3日星期五

Booleans in Python

bool(1j)

“Is the complex number 1j considered True or False?”

- 1j is a complex number with real part 0 and imaginary part 1.

- In Python, any nonzero number (whether int, float, or complex) evaluates to True when converted to bool.

- Only 0, 0.0, or 0j (complex zero) evaluate to False.

A complex number is a number that has two parts:

z=a+bj

  • a → the real part (ordinary number line)
  • b → the imaginary part (multiplied by j in Python, or i in mathematics)

Key ideas

  • The imaginary unit j (or i in math) is defined as \sqrt{-1}.
  • Complex numbers extend the real numbers so we can solve equations like x^2+1=0, which has no real solution but has complex solutions x=\pm i.

Visual intuition

You can think of complex numbers as points on a 2D plane:

  • The horizontal axis = real part
  • The vertical axis = imaginary part
    So 3+4j is the point (3, 4).

bool('')

you’re converting an empty string ('') into a boolean value.

Rule

  • Empty sequences/collections (like '', [], {}, ()) evaluate to False.
  • Non-empty sequences/collections (like 'hello', [1], (0,)) evaluate to True.

[]List

  • A list is an ordered, mutable sequence of elements.
  • You can store mixed types (numbers, strings, other lists).
  • Lists allow indexing, slicing, and modification
my_list = [1, 2, 3, "hello"]
my_list.append(4)       # add element
print(my_list[0])       # access first element → 1

"hello" is indeed the fourth element (index 3, since Python starts counting at 0). 

{}Dictionary (or empty set, depending on usage)
  • By default, {} creates an empty dictionary.
  • A dictionary stores key-value pairs.
  • Keys must be unique and immutable (like strings, numbers, tuples).
my_dict = {"name": "Alice", "age": 25}
print(my_dict["name"])   # → Alice

()Tuple
  • A tuple is an ordered, immutable sequence.
  • Similar to a list, but you cannot change its contents after creation.
  • Often used for fixed collections of items.

my_tuple = (10, 20, 30) print(my_tuple[1]) # → 20

Data structures include list, tuple, dictionary and set.

explicit: clear and easy to understand, so that you have no doubt what is meant

a = 5

b = 5

if a - b:

    print('a and b are not equal!')

No output will be printed.

weatherIsNice = True
haveUmbrella = False

if not (haveUmbrella or weatherIsNice):
    print('Stay inside')
else:
    print('Go for a walk')

1. weatherIsNice = True
2. haveUmbrella = False
3. Inside the if condition:
-(haveUmbrella or weatherIsNice) → evaluates to (False or True)True.
-not (True)False.
4. Since the condition is False, the else block runs.

Logic explained
  • The condition says: “If you do not have an umbrella and the weather is not nice, then stay inside.”
  • In this case, the weather is nice, so you can go for a walk even without an umbrella.
weatherIsNice = True
haveUmbrella = False

if (not haveUmbrella) and (not weatherIsNice):
    print('Stay inside')
else:
    print('Go for a walk')

Logic

This condition means:

  • “Stay inside only if you don’t have an umbrella and the weather is not nice.”
  • In this case, the weather is nice, so you go for a walk.
weatherIsNice = True
haveUmbrella = False

if haveUmbrella or weatherIsNice:
    print('Go for a walk')
else:
    print('Stay inside')

Logic

This condition means:

  • “If you either have an umbrella or the weather is nice, then go for a walk.”
  • Only if both are false (no umbrella and bad weather) will it print “Stay inside.”
Microsoft Copilot

藏書票

藏書票 (Ex Libris) 被譽為「紙上寶石」或「書上蝴蝶」,是一種黏貼在書籍扉頁(書冊封面後的第一頁)上的微型版畫,用來標示書籍的所有權。

Explained mainly by Google Gemini

The Birth of Microsoft

It was Paul who had the next thought: Since we were writing software for microcomputers, how about combining those two words? I agreed. We had our name: Micro-Soft.

sip: ​to drink something, taking a very small amount each time

MITS: Micro Instrumentation and Telemetry Systems

flabbergasted: extremely surprised and/or shocked

stunned: ​very surprised or shocked; showing this

A retrorocket (or retro-rocket) is a small, auxiliary rocket engine designed to produce thrust opposite to a spacecraft’s motion, enabling deceleration, braking, or maneuvering.

Altair is a global technology company providing software and AI solutions for simulation, data analytics, and high-performance computing (HPC).

A flagging economy refers to a nation's financial system that is becoming weaker, slower, or less effective, often characterized by low growth, rising unemployment, or reduced consumer spending.

the brink (of something) if you are on the brink of something, you are almost in a very new, dangerous or exciting situation

bankruptcy: IPA[ˈbæŋkrʌptsi]

prototype (for/of something) the first design of something from which other forms are copied or developed

mock-up: a model or a copy of something, often the same size as it, that is used for testing, or for showing people what the real thing will look like

cobble together: to produce something quickly and without great care or effort, so that it can be used but is not perfect

deluge: a large number of things that happen or arrive at the same time

stuff: to fill a space or container tightly with something

innards: the parts inside a machine

surpass: ​to do or be better than somebody/something

pay off: (informal) (of a plan or an action, especially one that involves risk) to be successful and bring good results

The gamble paid off.

artisanal: made in a traditional way by someone who is skilled with their hands

gravitas: the quality of being serious

behemoth: ​something that is very big and powerful, especially a company or organization

cloak: a thing that hides or covers somebody/something

ominously: ​in a way that suggests that something bad is going to happen in the future

DARPA stands for the Defense Advanced Research Projects Agency.

bean counter: a person who works with money, for example as an accountant and who wants to keep strict control of how much money a company spends

sole: only; single

lofty: very high and impressive

rudimentary: dealing with only the most basic matters or ideas


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Google AI overview

2026年3月23日星期一

Partial metering

Partial metering is especially useful when photographing a backlit subject because it prioritizes exposure on the subject itself, ensuring they aren’t rendered too dark against a bright background. The trade-off is that the background often becomes overexposed, but this can be used creatively.

逆光攝影(Backlit Photography)是指將主光源(通常是太陽或燈光)置於主體正後方的一種佈光方式。這種技巧能為照片增添戲劇感、層次感和一種夢幻般的視覺效果。

Microsoft Copilot

Google Search Engine AI Mode

Numbers in Python

int('100', 2)

means: convert the string '100' into an integer, interpreting it as a binary number.

A floating point error usually refers to the small inaccuracies that occur when computers represent and calculate with decimal numbers.

from decimal import Decimal, getcontext

The decimal module in Python is designed to avoid the floating point errors we just talked about. By using Decimal objects, you can represent numbers exactly as decimal fractions, and you can even control the precision of calculations with getcontext.

getcontext().prec = 4

round(0.1 + 0.2, 1)  # 0.3

Microsoft Copilot

測光

在攝影中,矩陣模式(Matrix Metering),通常也被稱為評價測光(Evaluative Metering)、多區測光或平均測光,是現代數碼相機中最智能化、最常用的測光模式。

Nikon:矩陣測光 (Matrix Metering)

Canon:評價測光 (Evaluative Metering)

Sony:多重測光 (Multi-segment Metering) 

Google AI Overview

2026年3月17日星期二

Macro lens

微距鏡拍攝時背景模糊的主要原因是景深極淺。鏡頭在近距離對焦時,清晰範圍非常有限,導致主體清晰而背景自然模糊。這種效果是微距攝影的特徵之一。

為什麼微距鏡背景容易模糊?

景深淺

微距鏡在近距離拍攝時,即使使用小光圈,景深仍然非常有限。只有焦點附近的區域清晰,其他部分迅速失焦,形成背景模糊。

放大倍率高

微距鏡能將物體放大到 1:1 或更高比例,這會進一步壓縮景深,使背景更容易模糊。

對焦距離短

微距鏡的最近對焦距離通常只有幾十公分甚至更短,這種近距離拍攝本身就會造成背景失焦。

Macro lenses have an extremely shallow depth of field (DOF), often measured in millimeters or less, because of the high magnification and short focusing distance. This is why only a tiny part of the subject is sharp while the rest quickly falls out of focus.

Microsoft Copilot