搜尋此網誌

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

2026年4月13日星期一

Investigation

summon somebody (to something) | summon somebody to do something (formal) to order somebody to come to you

preamble: an introductory fact or circumstance

rack up: to collect something, such as profits or losses in a business, or points in a competition

flabbergasted: ​extremely surprised and/or shocked

"Crunch through" generally means to persistently and quickly process a large amount of work, data, or obstacles, often under pressure.

sneak: to go somewhere secretly, trying to avoid being seen

accomplice: ​a person who helps another to commit a crime or to do something wrong

far-fetched: difficult to believe and unlikely to be true

contrition: ​the feeling of being very sorry for something bad that you have done

ramification: one of a number of complicated and unexpected results that follow an action or a decision

idle: (of machines, factories, etc.) not in use

peril: serious danger

reimburse: to pay back money to somebody which they have spent or lost

grievous: ​very serious and often causing great pain or difficulty

expunge something (from something) to remove or get rid of something, such as a name, piece of information or a memory, from a book or list, or from your mind

gulp: to swallow, but without eating or drinking something, especially because of a strong emotion such as fear or surprise

succinct: expressed clearly and in a few words

intimidating: ​frightening in a way that makes a person feel less confident

explicit: (of a statement or piece of writing) clear and easy to understand, so that you have no doubt what is meant

verdict: an official judgement made in court or at an inquest

roughshod: to treat somebody badly and not worry about their feelings

regent: a member of a governing board (as of a state university)

standout: a person or thing that is very easy to notice because they are or it is better, more impressive, etc. than others in a group

critique: ​a piece of written criticism of a set of ideas, a work of art, etc.

the advent of something/somebody the coming of an important event, person, invention, etc.

conciliatory: ​having the intention or effect of making angry people calm

blot: ​a spot or dirty mark on something, made by ink (= colored liquid in a pen), etc.

hamper somebody/something to prevent somebody from easily doing or achieving something

pursuit: the act of looking for or trying to get something

admonish: to tell somebody strongly and clearly that you do not approve of something that they have done

parlance: a particular way of using words or expressing yourself, for example one used by a particular group


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

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