搜尋此網誌

2026年7月29日星期三

Function Structure

A tuple in Python is one of the basic data structures, similar to a list but with some important differences.

Defined with parentheses ( )

my_tuple = (1, 2, 3)

Ordered → elements keep their position.

Immutable → once created, you cannot change, add, or remove elements.

Can contain mixed data types (numbers, strings, even other tuples).

Supports indexing and slicing like lists.

# Creating a tuple t = ('apple', 'banana', 'cherry') # Accessing elements print(t[0]) # 'apple' print(t[-1]) # 'cherry' # Slicing print(t[0:2]) # ('apple', 'banana') # Nested tuple nested = (1, (2, 3), 4) print(nested[1][0]) # 2

Negative indexing

  • In Python, negative indices count from the end of the sequence.

  • -1 → last element

Slice notation [start:stop]

  • start = 0 → begin at index 0 ('apple').

  • stop = 2 → go up to index 2, but not including it.

There is no difference in slicing syntax or behavior between lists and tuples. Both are sequence types in Python, so slicing works the same way.

# List
lst = ['apple', 'banana', 'cherry']
print(lst[0:2])   # ['apple', 'banana']

# Tuple
t = ('apple', 'banana', 'cherry')
print(t[0:2])     # ('apple', 'banana')

def performOperation(*args):
    print(args)
    
performOperation(1,2,3)

The * before args means: “pack all extra positional arguments into a tuple.”
Inside the function, args is a tuple containing whatever values you passed in.

def performOperation(*args, **kwargs): print(args) print(kwargs) performOperation(1, 2, 3, operation='sum')

*args

Collects all positional arguments into a tuple.
Here: args = (1, 2, 3)

**kwargs
Collects all keyword arguments into a dictionary.
Here: kwargs = {'operation': 'sum'}

Output:
(1, 2, 3) {'operation': 'sum'}

When you pass arguments like operation='sum', Python treats operation as a keyword.
Inside the function, **kwargs collects all keyword arguments into a dictionary.

>>> my_dict = {"operation": "sum", "message": "Hello"}
... print(my_dict["operation"])  # sum
...
sum

import math def performOperation(*args, operation='sum'): if operation == 'sum': return sum(args) if operation == 'multiply': return math.prod(args) performOperation(1,2,3,6,7,8, operation='sum')

Function Definition

  • *args → packs all positional arguments into a tuple. Here: args = (1, 2, 3, 6, 7, 8)

  • operation='sum' → keyword argument with default value 'sum'.

print(performOperation(1,2,3,6,7,8, operation='multiply'))
Uses math.prod(args) → multiplies all values.
math.prod stands for “product” — it multiplies all the numbers in an iterable together.

Microsoft Copilot

以基本的器材去提昇技術

Please comment on Canon EOS 1500D pairing with EF 35mm f/2 IS USM and EF-S 18-135mm f/3.5-5.6 IS USM while I rarely take video and fast-moving objects.

For your Canon EOS 1500D, the EF 35mm f/2 IS USM is the stronger choice if you mostly shoot still photos and care about image quality, while the EF-S 18-135mm f/3.5-5.6 IS USM is the more flexible all-in-one lens. Since you rarely shoot video or fast action, I’d lean toward the 35mm prime as the more satisfying “main lens,” with the 18-135mm only if you want convenience over optical depth.

How they fit your use

EF 35mm f/2 IS USM: On APS-C, it behaves like about a 56mm equivalent, which is great for everyday shots, portraits, food, indoor scenes, and general street photography. Its wider f/2 aperture gives you better low-light performance and blurrier backgrounds than the zoom.

EF-S 18-135mm f/3.5-5.6 IS USM: This is the better travel/everything lens, because it covers wide to short telephoto and has fast, quiet autofocus plus stabilization. Reviews describe it as versatile and quick for stills, but image quality is more “good enough” than exceptional, especially wide open.

For your shooting style

Because you said you rarely take video and fast-moving objects, the 18-135mm’s main advantages matter less. The Nano USM and motorized-zoom compatibility are especially useful for smooth, quiet video operation. The lens is quick enough for action, but that advantage is mainly relevant when subjects are moving rapidly. If you mostly shoot static or slower subjects, you won’t exploit that speed much.

The 35mm prime will usually give you more pleasing images, better subject separation, and a more compact setup for everyday use.

Practical recommendation

Pick EF 35mm f/2 IS USM if you want one lens for daily still photography and are happy to “zoom with your feet.”

Pick EF-S 18-135mm f/3.5-5.6 IS USM if you want one lens to cover many situations without changing lenses.

Best overall setup for your use: keep the 18-135mm for convenience, and add the 35mm f/2 for better-quality indoor/night portraits and general photography.

www.perplexity.ai

測光模式


Evaluation metering: general purpose metering mode suited even for backlit subjects. The camera sets the exposure automatically to suit the scene.

Partial metering: Effective where there are much brighter lights around the subject due to backlight, etc. The gray area in the figure of the user manual is approximately where the brightness is metered to obtain the standard exposure.

Center-weighted average metering: The brightness is metered at the image center and then averaged for the entire scene. This metering mode is for advanced users.

運用框景構圖時要注意的地方是,會讓相片被拍得太過明亮,這類曝光無法符合心中所想所要的境界之情況。拍攝相片時,最好先將測光模式設定為「中央重點測光」。

上田晃司《全圖解 馬上提昇功力的57個攝影妙方:一目了然的專業級表現手法!》

Backlit Subject Photography
  • Focus: The subject itself is the emphasis.

  • Definition: The subject is positioned with a light source behind them, so the camera captures the subject against that light.

  • Effect: The subject may appear darker, with rim lighting around edges (hair, shoulders).

  • Usage: Portraits, fashion, or street photography where the subject’s outline and glow are important.

  • Challenge: Subject exposure can be tricky — often requires fill flash, reflectors, or exposure compensation.

Backlight Photography

  • Focus: The lighting technique.

  • Definition: Any photography that uses a light source behind the subject, regardless of whether the subject is the main focus.

  • Effect: Creates atmosphere, depth, and contrast. Can produce silhouettes (輪廓), glowing edges, or dramatic mood.

  • Usage: Landscape (sunset silhouettes), product photography (transparent objects), creative effects.

  • Challenge: Managing flare and overexposure of the background.

Practical Tips

  • For portraits: Use partial metering on the face to keep the subject properly exposed.

  • For silhouettes: Use evaluative metering so the background is exposed correctly and the subject stays dark.

  • Extra help: Add fill flash or a reflector to brighten the subject, or use exposure compensation (+1 to +2 EV).

Microsoft Copilot

starting point

catch on: to become popular or fashionable

ballpoint pen: a pen with a very small metal ball at its point, that rolls ink (= colored liquid for writing, etc.) onto the paper

miniature: very small; much smaller than usual

garage: a building for keeping one or more cars or other vehicles in

distributor: a person or company that supplies goods to shops, etc.

To "gush over" someone or something means to express overwhelming or excessive emotion, praise, or enthusiasm.

fray: a fight, a competition or an argument, especially one that is exciting or seen as a test of your ability

swoop: to visit or attack somebody/something suddenly and without warning

hassle: a situation that is annoying because it involves doing something difficult or complicated that needs a lot of effort

a handful: (informal) a person or an animal that is difficult to control

harangue: to speak loudly and angrily in a way that criticizes somebody/something or tries to persuade people to do something

square with: to make two ideas, facts or situations agree or combine well with each other; to agree or be consistent with another idea, fact or situation

gruff: impatient and unfriendly

NCR: National Cash Register

JFK: John F. Kennedy International Airport

Hauppauge Computer Works is a US manufacturer and marketer of electronic video hardware for personal computers.

thwart: to prevent somebody from doing what they want to do

protracted: lasting longer than expected or longer than usual

back-and-forth: discussion

work out: ​to develop in a successful way

branch out: diversify

The Chevrolet Corvette is an iconic American high-performance sports car manufactured by General Motors since 1953.

opt out: ​to choose not to take part in something

parody: (disapproving) something that is such a bad or an unfair example of something that it seems silly

grandiose: seeming very impressive but too large, complicated, expensive, etc. to be practical or possible

veep: vice-president

meticulous: paying careful attention to every detail

artifact: an object that is made by a person, especially something of historical or cultural interest

MOS Technology, Inc. ("MOS" being short for Metal Oxide Semiconductor), later known as CSG (Commodore Semiconductor Group) and GMT Microelectronics, was a semiconductor design and fabrication company based in Audubon, Pennsylvania.

Off-putting is an adjective that means unpleasant, unappealing, or slightly worrying, making you want to stop liking or avoid a person or thing.

meanwhile (informal meantime): while something else is happening

envision: (formal) to imagine what a situation will be like in the future, especially a situation you intend to work towards

daunting: making somebody feel nervous and less confident about doing something; likely to make somebody feel this way

Bill Gates "Source Code"

hk.dictionary.search.yahoo.com

oxfordlearnersdictionaries.com

www.merriam-webster.com

en.wikipedia.org

2026年7月28日星期二

避免火遮眼

Second guessing means to doubt your own choice after you make it, to question someone else's past decision, or to try and guess what will happen next.

dictate: to control or influence how something happens

rampant: (of something bad) existing or spreading everywhere in a way that cannot be controlled

rage: a feeling of violent anger that is difficult to control

reinstate: to give back a job or position that had been taken away from somebody

panoramic: with a view of a wide area of land

By widening your field of vision, you can reduce the tunnel vision that is associated with roaring anger... It also affords you a few minutes to get distance from the scenario an your environment so that you can get clarity.

當你把注意力從狹窄的焦點擴展到周圍環境時,情緒的專注和衝動會減弱,較不容易被憤怒完全佔據。幾分鐘的緩衝時間讓你從當下情境和環境中拉開距離,冷靜下來以便看清狀況、做出更清晰理性的判斷。

tunnel vision: (disapproving) a lack of ability to see or understand all the aspects of a situation, an argument, etc. instead of just one part of it

mitigate: to make something less harmful, serious, etc.

spout: (informal, disapproving) to speak a lot about something; to repeat something in a boring or annoying way

Nicole Vignola "Rewire"

hk.dictionary.search.yahoo.com

oxfordlearnersdictionaries.com

www.merriam-webster.com

Explanation by Microsoft Copilot

2026年7月22日星期三

Bellflower Motif

建築上的「風鈴草」是指源自西方古典與傳統建築裝飾中的風鈴草紋飾(Bellflower Motif),常見於柱頭、角柱或外牆線條中。 

風鈴草紋飾的建築特徵

外形設計:模仿桔梗科風鈴草屬植物的鐘形花朵或成串果莢,呈現風格化、垂直下垂的花彩狀造型。

應用部位:多見於新古典主義或戰前唐樓建築的騎樓角柱、柱頭飾線、露台支柱上方或牆面灰塑雕飾。

歷史實例:如香港深水埗醫局街170號(建於1913年)戰前騎樓的角柱上,便飾有極為迷你的風鈴草立體紋飾。 

Google AI overview

Chapter Quiz

wait_until = datetime.now().second + 2

while datetime.now().second != wait_until:

    print('Still waiting!')

print(f'We are at {wait_until} seconds!')


  • datetime.now().second gives you the current second (0–59) of the system clock.

  • You add 2 to it, so if the current second is 15, then wait_until becomes 17.

  • This means you want to wait until the clock reaches 17 seconds.


while datetime.now().second != wait_until: print('Still waiting!')

  • This is a loop that keeps checking the current second.

  • As long as the current second is not equal to wait_until, it prints "Still waiting!".

  • Example: If the current second is 15, and wait_until is 17, it will keep printing "Still waiting!" until the clock reaches 17 seconds.

Problem here: If wait_until goes beyond 59 (e.g., current second = 58 → wait_until = 60), the value 60 doesn’t exist in the clock (seconds only go 0–59). That means the loop will never end.


print(f'We are at {wait_until} seconds!')

Once the loop ends (meaning the current second equals wait_until), this line runs.

It prints a message like:

We are at 17 seconds!

Example Run:

Suppose the current second is 15:

  1. wait_until = 15 + 2 = 17

  2. While the clock is at 15 or 16, it prints "Still waiting!".

  3. When the clock hits 17, the loop ends.

  4. It prints "We are at 17 seconds!".


Your code works fine if wait_until stays within 0–59. But if the current second is 59, then wait_until = 61, which will never happen. To fix this, you should use modulo (% 60) to wrap around:

wait_until = (datetime.now().second + 2) % 60

That way, if the current second is 59, wait_until becomes 1 (the next minute’s first second), and the loop will still work.

['Monty Python' if n % 6 == 0 
 else 'Python' if n % 3 == 0 
 else 'Monty' if n % 2 == 0 
 else n 
 for n in range(1, 10)]

Step 1: Understanding the structure

  • This is a list comprehension that loops n from 1 to 9 (range(1, 10)).

  • For each n, it checks conditions in order:

    1. If divisible by 6 → 'Monty Python'

    2. Else if divisible by 3 → 'Python'

    3. Else if divisible by 2 → 'Monty'

    4. Else → just the number n


Step 2: Condition priority

The conditions are evaluated top to bottom:

  • % 6 == 0 has highest priority.

  • If that fails, % 3 == 0 is checked.

  • If that fails, % 2 == 0 is checked.

  • If all fail, return the number itself.


Step 4: Final output

So the list becomes:

[1, 'Monty', 'Python', 'Monty', 5, 'Monty Python', 7, 'Monty', 'Python']


In Python, break is used inside loops to immediately exit the loop, no matter what the loop condition is. Let’s go step by step:

How break works

  • Normally, a while or for loop keeps running until its condition becomes false.

  • If you use break, the loop stops right away—even if the condition is still true.

  • After breaking, the program continues with the code that comes after the loop.


Example with while

n = 1
while n < 10:
    print(n)
    if n == 5:
        break   # exit loop when n == 5
    n += 1

print("Loop ended")

Output:

1
2
3
4
5
Loop ended

range(1, 9) in Python creates a sequence of integers starting at 1 and stopping before 9.


Microsoft Copilot