搜尋此網誌

2026年6月2日星期二

Part I of Python test

def encodeString(stringVal):

    encodedList = []

    prevChar = stringVal[0]

    count = 0


    for char in stringVal:

        if prevChar != char:

            encodedList.append((prevChar, count))

            count = 0

            prevChar = char

        count = count + 1


    encodedList.append((prevChar, count))

    return encodedList


Step 1: Setup

  • encodedList = [] → empty list to store results.

  • prevChar = stringVal[0] → start with the first character of the string.

  • count = 0 → counter for consecutive occurrences.


Step 2: Loop through each character

for char in stringVal:

Goes through every character in the string one by one.


Step 3: Check if the character changes

if prevChar != char:
    encodedList.append((prevChar, count))
    count = 0
    prevChar = char

If the current character is different from the previous one:

  • Save the previous character and its count into encodedList.

  • Reset count to 0.

  • Update prevChar to the new character.


Step 4: Count occurrences

count = count + 1

Always increment the counter for the current character.


Step 5: Add the last group

encodedList.append((prevChar, count))

After the loop finishes, add the final character group to the list.


Step 6: Return result

return encodedList

The function returns the list of (character, count) tuples.

Microsoft Copilot

Naughty

catnap: a short sleep

pickled: (of food) preserved in vinegar

chile con queso: (in Tex-Mex cooking) a thick sauce of melted cheese seasoned with chilli peppers, typically served warm as a dip for tortilla chips

bequeath: pass (something) on or leave (something) to someone else

Plymouth was a beloved American automobile brand produced by the Chrysler Corporation from 1928 until 2001.

tow: to pull a car, boat, etc. behind another vehicle, using a rope or chain

junkyard: a place where old cars, machines, etc. are collected, so that parts of them, or the metal they are made of, can be sold to be used again

a chunk of: (informal) a fairly large amount of something

fetch: to go to where somebody/something is and bring them/it back

cruising: (of a car, etc. or its driver) to drive along slowly, especially when you are looking at or for something

rear-wheel drive: a system in which power from the engine is sent to the back wheels of a vehicle

fishtail: if a vehicle fishtails, the back end slides from side to side

joyriding: the crime of stealing a car and driving it for pleasure, usually in a fast and dangerous way

barbed wire: strong wire with short sharp points on it, used especially for fences

bail out: to escape from a situation that you no longer want to be involved in

pint: a pint of beer (especially in a pub)

foible: a silly habit or a strange or weak aspect of a person’s character that is not considered serious by other people

frenzy: a state of great activity and strong emotion that is often violent or frightening and not under control

attribute something to something: to say or believe that something is the result of a particular thing

intimidate: to frighten or threaten somebody so that they will do what you want

deferential: showing that you respect somebody/something, especially somebody older or more senior than you

"To get a kick out of" is an idiom that means to really enjoy something, or to get a strong feeling of excitement and pleasure from doing or experiencing it.

bemused: showing that you are confused and unable to think clearly

bide: to stay or live in a place

insubordination: the act of refusing to obey orders or show respect for somebody who has a higher rank

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Google AI overview

2026年5月28日星期四

Dictionary Comprehensions in Python

Revision:

In Python, lists, tuples, sets, and dictionaries are all built-in data structures, but they differ in mutability, ordering, and how they store data. Lists and dictionaries are mutable, tuples are immutable, and sets enforce uniqueness. Dictionaries store key–value pairs, while the others store single values.

List: [ ]

Tuple: ( )

Set: { } or set()

Dictionary: {key: value}


myList = [1,2,3,4,5]

[2*item for item in myList]

This a list comprehension, not a for loop.

In a for ... in loop, the colon (:) is mandatory because it introduces a block of indented code.

for item in myList:

    print(2*item)


We can use any valid variable name instead of "item" in a for ... in loop or a list comprehension. The name is just a placeholder that represents each element in the sequence while iterating.

What is a Key–Value Pair?

A dictionary is like a real-world dictionary:
Key = the word you look up.
Value = the definition you get.

In Python:
Key must be unique and immutable (string, number, tuple).
Value can be anything (string, number, list, another dict, etc.).

person = {
    "name": "Alice",
    "age": 25,
    "city": "Hong Kong"
}

"name" → key, "Alice" → value
"age" → key, 25 → value
"city" → key, "Hong Kong" → value

animalList = [('a', 'anteater'), ('b', 'bear'), ('c', 'cat'), ('d', 'dog')]
animals = {item[0]: item[1] for item in animalList}
animals

List of tuples
[('a', 'anteater'), ('b', 'bear'), ('c', 'cat'), ('d', 'dog')]

Each tuple has two elements:
item[0] → the key (like 'a')
item[1] → the value (like 'anteater')

Dictionary comprehension
{item[0]: item[1] for item in animalList}

Loops through each tuple in animalList.
Uses the first element (item[0]) as the key.
Uses the second element (item[1]) as the value.

{'a': 'anteater', 'b': 'bear', 'c': 'cat', 'd': 'dog'}

>>> animalList = [('a', 'anteater'), ('b', 'bear'), ('c', 'cat'), ('d', 'dog')]
>>> animals = {key: value for key, value in animalList}
... animals
...
{'a': 'anteater', 'b': 'bear', 'c': 'cat', 'd': 'dog'}

animals.items()
dict_items([('a', 'anteater'), ('b', 'bear'), ('c', 'cat'), ('d', 'dog')])
Asking Python to give you all the key–value pairs in the dictionary.

list(animals.items())
[('a', 'anteater'), ('b', 'bear'), ('c', 'cat'), ('d', 'dog')]

A list comprehension that builds a list of dictionaries from your animals dictionary
[{'letter': key, 'name': value} for key, value in animals.items()]

animals.items()
Produces key–value pairs like:
('a', 'anteater'), ('b', 'bear'), ('c', 'cat'), ('d', 'dog')

Looping with for key, value in animals.items()
Each iteration unpacks the tuple into key and value.

Dictionary inside the comprehension
For each pair, you create a new dictionary:
{'letter': key, 'name': value}

Result:
[{'letter': 'a', 'name': 'anteater'}, {'letter': 'b', 'name': 'bear'}, {'letter': 'c', 'name': 'cat'}, {'letter': 'd', 'name': 'dog'}]

Microsoft Copilot

Startup Company

bear down on: to move quickly toward someone or something in a determined way

get something off the ground: to start happening successfully; to make something start happening successfully

payroll: a list of people employed by a company showing the amount of money to be paid to each of them

mundane: not interesting or exciting

monte: a card game

viable: that can be done; that will be successful

topology: a branch of mathematics concerned with those properties of geometric configurations (such as point sets) which are unaltered by elastic deformations (such as a stretching or a twisting) that are homeomorphisms

disabuse somebody (of something) to tell somebody that what they think is true is, in fact, not true

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

2026年5月26日星期二

西九文化區日落美景

 

Aperture Priority (光圈先決): f/9

ISO: 100

(Shutter Speed) 快門: 1/100 second

Focal Length (焦距): 135mm

Equivalent Focal Length (等效焦距): 216mm

Tripod Used and Image Stabilizer Off

White Balance (白平衡): Shade (陰影模式)

效果:相機會自動加暖色調,橘色比肉眼看更明顯

負曝光補償(Exposure Compensation): -1ev

Landscape Picture Style (Contrast: +1, Saturation: +1)

Evaluative Metering (權衡式測光)

Safety Precautions of Tripod Usage

Manfrotto MKBFRTA4GT-BH

Designed for the advanced travel photographer, this tripod is extremely portable and solid. Ideal for mirrorless cameras or medium format DSLRs.

Key features:

  • Side-pull leg angle selector for fast adjustment
  • Legs can be independently set at 3 angles of spread
  • Ball head for quick and easy framing
  • Rubber leg warmer (pads for camera tripod legs) for comfortable grip
  • Easy link socket for arms and other accessories
  • Fast and secure twist lock system
  • Counterweight hook for extra stability and strap attachment
      Set Up

Unfold the legs as shown in figure 1.
Open the 3 tripod legs. To adjust the tripod's height, release the telescopic extensions on each leg by rotating Twistlock "A" about a quarter of a turn.

You should open the proximal (top) twist‑lock first, then the distal (lower) sections, when extending the legs.

      Leg Angle Adjustment

Each leg can be set independently at any of the 3 angles of spread. To change the angle on a leg, close the leg slightly towards the center column and press down the locking button "W" at the top of the leg. While pressing the button, select the new leg angle and then release button "W" to lock in position, then open the leg fully again. The angle of each leg can be adjusted independently of the other two legs.

Warning: During this procedure, please take care not to insert your fingers inside the central aperture on the spider collar.

     Adjusting Center Column Height

To release the center column "C", unlock gear "D" and adjust the height of the column as required. Tighten gear "D" to lock the column in position.

     Fitting the Quick Release Plate to the Camera

Fix plate "G" to the base of the camera by tightening camera screw in the camera's threaded tripod hole using the ring "Q" WITHOUT APPLYING FORCE. Before fully locking, align the plate "G" with the camera lens. Please ensure you have securely fastened plate "G" to the camera before use. Once fastened, push ring "Q" down so that it lies flat against the plate "G".

    Mounting the Camera on the Head

To mount the camera on the head, open lever "H" while pushing safety catch "X" down, holding them both in the open position whilst attaching the camera by slotting camera plate "G" into the top of the head as shown in figure 5. Release lever "H" and safety catch "X".

Warning: Make sure that the camera is securely locked to the head by pushing lever "H" against plate "G" (Figure 6) and checking that the camera does not move in the head.
From my practical usage experience, lever "H" cannot be completely pushed against plate "G". The reason is the indicated orientation (arrow towards lens) of the plate "G" is reversed.

    Use

The head has independent panoramic and tilt movement.
The lever "F" locks the panoramic movement.
To release the movement, unlock lever "F" by rotating anticlockwise.
Once the desired position is achieved, lock the head by turning lever "F" fully clockwise.

Warning: The lever "P" locks the ball's movement. To ensure safety when using the ball head, always hold the camera with one hand while releasing the ball.

To release the ball "L" when positioning the camera, unlock lever "P" by rotating anticlockwise.
Once the desired position has been reached, lock the ball "L" by turning lever "P" by rotating fully clockwise.
The head features independent fiction adjustment on the ball movement, which makes it easier to position the head before locking it. To adjust the fiction, ensure the ball "L" is not locked. Then hold the camera in one hand and rotate knob "N" clockwise to increase friction. Friction does not lock the camera: we recommended locking the ball "L" by turning the lever "P" fully.

Tripod Manual
Microsoft Copilot
Perplexity AI

2026年5月20日星期三

Software for chip

Bill Gates and Paul Allen kick-started the personal computer revolution by writing Altair BASIC in 1975 to run on the Altair 8800. This software was the first product of their newly formed company, Microsoft.

Stephen Gary Wozniak is an American technology entrepreneur, electrical engineer, computer programmer, and inventor. In 1976, he co-founded Apple Computer (now Apple Inc.) with his early business partner Steve Jobs. Through his work at Apple in the 1970s and 1980s, he is widely recognized as one of the most prominent pioneers of the personal computer revolution.

The Homebrew Computer Club was an early computer hobbyist group in Menlo Park, California, which met from March 1975 to December 1986.

Monte Davidoff is an American computer programmer who was one of the first employees of Microsoft.

couch: a long piece of furniture like a bed, especially in a doctor’s office

rug: a piece of thick material like a small carpet that is used for covering or decorating part of a floor

Traf-O-Data was a business partnership founded in 1972 by Bill Gates, Paul Allen, and Paul Gilbert. The company aimed to read raw data from roadway traffic counters and process it into usable reports for traffic engineers.

reams: reams [plural] (informal) a large quantity of writing

dividend: ​an amount of the profits that a company pays to people who own shares in the company

realm: an area of activity, interest or knowledge

exclusive: only to be used by one particular person or group; only given to one particular person or group

royalty: a sum of money that is paid to somebody who has written a book, piece of music, etc. each time that it is sold or performed

cap at: set as the upper limit

sublicense: a license granted to a third party by a licensee, extending some rights or privileges that the licensee enjoys

viable: feasible; that can be done; that will be successful

ruminate: to think deeply about something

confide: to tell somebody secrets and personal information that you do not want other people to know

goof around: (especially North American English, informal) to spend your time doing silly or stupid things

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Google AI Overview

en.wikipedia.org