๐Ÿ“š CIT Revision Notes
๐Ÿ’ป Computer Information Technology ่ค‡็ฟ’็ญ†่จ˜

๐Ÿ“‘ ็›ฎ้Œ„ / Table of Contents

โš ๏ธ Must-Remember Exam Points (้ซ˜้ ป่€ƒ้ปž) ๐Ÿ”ฅ

  • โŒComparison in if โ†’ Use == (two equal signs), NOT =
  • ๐Ÿ“ฆAlways import libraries first (e.g. import time before time.sleep())
  • input() always returns a string by default
  • ๐ŸŽฏKey functions:
    • tts.say() ๐Ÿ”Š
    • cloudspeech.recognise() ๐ŸŽค
    • cloudtranslation.translate() ๐ŸŒ
    • cloudvision.recognise() or take_photo() ๐Ÿ“ธ

1๏ธโƒฃ Core Concepts ๐Ÿง 

๐Ÿค– Artificial Intelligence (AI) ไบบๅทฅๆ™บๆ…ง
Machines that simulate human thinking ๐Ÿง , cognitive functions ๐Ÿ’ญ, learning from experience ๐Ÿ“š, and decision-making โšก.

๐ŸŒŸ Real-life Applications (ๆ—ฅๅธธๆ‡‰็”จ):

๐Ÿ“š Libraries ๅ‡ฝๅผๅบซ = Toolbox ๐Ÿงฐ containing useful functions ๅ‡ฝๆ•ธ (like trigonometric functions).
Example: import tts โ†’ then use tts.say()

โ˜๏ธ Google Colab
Free online Python editor. Notebooks saved automatically in Google Drive. Cells = Code + Text.

2๏ธโƒฃ Text-to-Speech (TTS) ๆ–‡ๅญ—่ฝ‰่ชž้Ÿณ ๐Ÿ”Š

๐Ÿ“ฆ Library: tts

๐Ÿ’ก Basic Code:

import tts
tts.say("Hello World!")

โš™๏ธ Advanced Parameters:

tts.say("Hello, how are you?", 
        pitch=-5,          # -20.00 to 20.00
        speaking_rate=0.5) # 0.25 to 4.00

๐ŸŒ Language Support:

  • English: "en-uk" ๐Ÿ‡ฌ๐Ÿ‡ง
  • Cantonese: "yue-HK" ๅปฃๆฑ่ฉฑ ๐Ÿ‡ญ๐Ÿ‡ฐ
  • Putonghua: "cmn-CN" ๆ™ฎ้€š่ฉฑ ๐Ÿ‡จ๐Ÿ‡ณ

๐ŸŽฏ English Lesson Missions:

3๏ธโƒฃ Variables ่ฎŠ้‡ ๐Ÿ“ฆ

๐Ÿ“Œ Definition: Named containers that store values.

๐Ÿ’ก Assignment:

x = "Hello World"
name = "Apple"

โš ๏ธ Rules for Variable Names (้‡่ฆ!):

  • โœ… Start with letter (A-Z, a-z) or _
  • โœ… Can contain letters, numbers, _
  • โŒ Cannot start with number
  • โŒ No spaces or special characters (! # $ etc.)
  • โŒ Cannot use keywords (import, class, if, print, etc.)
  • โšก Case-sensitive (name โ‰  NAME)

โœ… Examples:

  • four_dir, apple_pie, lesson, _final

โŒ Examples:

  • 4dir, apple pie, class, import

๐Ÿ–จ๏ธ Printing:

print(name)           # prints value
print("name")         # prints literal string "name"
print("Hello", name)  # mixes string + variable

๐Ÿ”„ Reassignment:

district = "Hong Kong"
district = "Kowloon"   # old value overwritten

4๏ธโƒฃ Keyboard Input โŒจ๏ธ

name = input("What is your name? ")
print("Hello", name)
  • ๐Ÿ“input() returns string
  • ๐Ÿ”Can use multiple input() calls
  • ๐Ÿ’ฌPrompt message appears before the input box

5๏ธโƒฃ Translation ็ฟป่ญฏ ๐ŸŒ

๐Ÿ“ฆ Library: cloudtranslation

๐Ÿ’ก Basic:

import cloudtranslation
result = cloudtranslation.translate("Hello")

๐ŸŒ With Language:

cloudtranslation.translate("Hello", lang="yue-HK")

๐ŸŽฏ Interactive Version (Mission):

  • Use input() for text
  • Use input() for target language code
  • Then translate

6๏ธโƒฃ Speech Recognition ่ชž้Ÿณ่ญ˜ๅˆฅ ๐ŸŽค

๐Ÿ“ฆ Library: cloudspeech

import cloudspeech
print("Say something...")
text = cloudspeech.recognise()
print("You said:", text)

๐Ÿ”„ Speech-to-Text Process:

  1. ๐Ÿ”Š Sound wave (analog)
  2. โšก Discretisation ้›ขๆ•ฃๅŒ– + Quantisation ้‡ๅŒ– โ†’ digital data
  3. ๐Ÿค– Machine matches pattern to words

7๏ธโƒฃ Arithmetic Operators โž•โž–๏ธโž—

Operation ้‹็ฎ— Operator ้‹็ฎ—็ฌฆ
Addition ๅŠ ๆณ•+
Subtraction ๆธ›ๆณ•-
Multiplication ไน˜ๆณ•*
Division ้™คๆณ•/

๐ŸŽฏ Example Missions:

  • Area of square: area = len * len ๐Ÿ“
  • Perimeter of circle: perimeter = 2 * PI * r โญ•

8๏ธโƒฃ Checkpoint Summary (ๅธธ่ฆ‹้กŒๅž‹) ๐Ÿ“‹

  • Checkpoint 1.1:
    • Correct print() quotes & syntax
    • Must import time before time.sleep(60)
  • Checkpoint 2.1:
    • Mixing strings & variables in print()
    • Valid variable names
    • Variable reassignment effect

9๏ธโƒฃ Smart Assistants & Virtual Assistants ๐Ÿค–

๐Ÿ’ฌ Virtual Assistant: AI that responds to natural language commands (weather, calendar, alarms).

๐Ÿค– Chatbots:

๐Ÿ”‘ Key Technologies:

  • Speech Recognition ่ชž้Ÿณ่ญ˜ๅˆฅ ๐ŸŽค
  • Natural Language Processing (NLP) ่‡ช็„ถ่ชž่จ€่™•็† ๐Ÿ’ฌ

๐Ÿ”Ÿ Quick Revision Tips ๐Ÿš€

  • ๐Ÿ›Debugging Order: Import โ†’ Quotes โ†’ == vs = โ†’ Variable names โ†’ Data types
  • ๐Ÿ’ปAlways run sample Colab notebooks
  • ๐Ÿ”„Practice interactive programs: Input โ†’ Translate โ†’ Speak
  • ๐Ÿ“Use meaningful variable names
  • Review all Missions (English Lesson, Super Translation Gadget, Arithmetic Genius)