ENGG1003
Digital Literacy and
Computational Thinking - P
Lab 01 Fun with Python
2023-24 Term 2
Lab Protocol
Bring your own computer to complete tasks
Students are required to participate in the lab
Discussion, Q&A, poll, uReply, etc.
You may talk to/chat with teacher and TA
Submit your work on Blackboard at the end of
the lab
2
Lab 01 Activities
Use your own Virtual Machine over Remote Desktop
Try simple Python commands interactively
Write some commands to calculate Body Mass Index
(BMI) – both interactively and in a code editor
Answer ALL questions in a "Test" on Blackboard
Extras – Just for Fun!
3
Setup and Use Your Own
VM
Got an invitation email recently?
Check your CUHK @Link Outlook email inbox
See luck in your spam/junk mail folder?
From: Microsoft Azure <azure-
noreply@[Link]>
Subject: Register for Lab – ENGG100...
See VM, Remoting and Cloud Computing
Using Microsoft Azure Labs [Link]
4
Yours is a Windows 11 VM
Double-click on the desktop icon
pythonIDLE
and wait…
5
Working Environment
Work on the white IDLE Shell
window
Do NOT close the black
command terminal window
6
Try Simple Python
Commands Interactively
Launch the installed app IDLE (Python) and try:
7
Try Simple Python
Commands Interactively
What do you see on entering this command?
copyright
What is the result of 3 / 2? This interactive mode of
operation is called Read-
Evaluate-Print-Loop (REPL)
What is the result of 4 / 3?
8
Calculate Body Mass Index
(BMI) immediately
where weight in kg, height in m
Try the following commands:
weight = 55 COPY AND PASTE ONE LINE AT
height = 1.73 A TIME!
bmi = weight / height**2
print("BMI = ", bmi)
This is a limitation of the IDLE
REPL…
Do NOT copy 4 lines at a time !! Copy one line at a
time!!
What do you see? What do think about the symbols ** ?
Try the above commands again with your own weight and
height
9
Create a New File (Code Editor)
VM / Windows User
10
Create a New File (Code Editor)
Mac User
11
Type Your Code, Customize with
your own SID, name and BMI
Copy and paste, edit
and try your code in a
managed way
Even draw something using commands!
12
Save Your Work Properly
Setup your own filing system: create a folder
for your works in ENGG1003
Keep on your own computer, e.g., Documents
Keep on portable storage such as USB drive
Keep on cloud storage such as OneDrive
(CUHK O365)
Folder structure is hierarchical, i.e., tree-like
with branches called sub-folders
13
Windows User
File Save [Ctrl+S]
14
Windows User
New folder
15
Windows User
Create New Folder
ENGG1003
16
Windows User
Save to File
ENGG1003_lab01.py
ENGG1003_lab01.py
17
Mac User
File Save OR
Run Run Module Save? Dialog
18
Mac User
Where: Create Folder
Save to File ENGG1003_lab01.py
19
Focus (Click) the Editor Window
Run Your Work (Hot-key F5)
20
More – Turtle Graphics
Have Fun!!
Python can handle not only numbers and text,
but also graphics!
import turtle as pet
[Link](100)
angle = 135
[Link](angle)
[Link](100)
[Link](angle/3) # 45
[Link](200)
21
Blackboard Submission
Login Blackboard course ENGG1003
Go to Labs Lab 01 Fun with Python
Answer ALL questions
You need NOT upload your code or .py file
Click [Submit] button
22
Notes to VM Users
The VM assigned to you will be available throughout the semester
All your files and works will be persistently kept on your own VM in the
cloud till the end of the term
You may copy-and-paste files between your VM and your other
computers
You may use Blackboard/uReply/OneDrive/O365 services on your VM
Shall you RESET your own VM, all data stored on your VM will be LOST!!
Start/Stop/Connect/Disconnect actions are FINE
23
Extras for Fun – Color
Spiral
Download and Run the given file [Link]
24