Professional Documents
Culture Documents
File 5045
File 5045
ENGG1810/9810
Introduction to Engineering Computing
Week 4: Repeating Actions II
COMMONWEALTH OF AUSTRALIA
WARNING
The material in this communication may be subject to copyright under the Act.
Any further reproduction or communication of this material by you may be the
subject of copyright protection under the Act.
Week 5: Functions I
Week 6: Functions II Functions
Week 7: Libraries and Modules I
and Packages
Week 9: Application I
ENGG1810/9810 Assessment
No. Assessment
1 Weekly Works (Lab Exercise)
2 Lab Test 1
3 Lab Test 2
4 Final Exam
ENGG1810/9810
What do we need
to plot this? Hmm…
ENGG1810/9810 Assessment
No. Assessment
1 Weekly Works (Lab Exercise)
2 Lab Test 1
3 Lab Test 2
4 Final Exam
ENGG1810/9810
Today’s Lecture
Python Collections
We have three students in ENGG1810/9810, BTS_V, Emma Watson, Spongebob
We plot their grades for each assessment item First, we need representing their name and grade for each item!
Then, for loop? and visualise with matplotlib?
What do we need
to plot this? Hmm…
ENGG1810/9810
Python Collections
We have three students in ENGG1810/9810, BTS_V, Emma Watson, Spongebob
We plot their grades for each assessment item First, we need representing their name and grade for each item!
Lists or Tuples
What do we need items = ['Weekly', 'LabTest1', 'LabTest2', 'FinalExam']
to plot this? Hmm…
btsv = [18, 8, 16, 45]
Dictionaries
bts_v = { emma = { sponge = {
“Weekly”: 18, “Weekly”: 20, “Weekly”: 10,
“LabTest1”: 8, “LabTest1”: 8, “LabTest1”: 4,
“LabTest2”: 16, “LabTest2”: 16, “LabTest2”: 14,
“FinalExam”: 45 “FinalExam”: 42 “FinalExam”: 35
} } }
ENGG1810/9810
Python Collections
We have three students in ENGG1810/9810, BTS_V, Emma Watson, Spongebob
We plot their grades for each assessment item First, we need representing their name and grade for each item!
Lists or Tuples
What do we need items = ['Weekly', 'LabTest1', 'LabTest2', 'FinalExam']
to plot this? Hmm…
btsv = [18, 8, 16, 45]
Dictionaries
bts_v = { emma = { sponge = {
“Weekly”: 18, “Weekly”: 20, “Weekly”: 10,
“LabTest1”: 8, “LabTest1”: 8, “LabTest1”: 4,
“LabTest2”: 16, “LabTest2”: 16, “LabTest2”: 14,
“FinalExam”: 45 “FinalExam”: 42 “FinalExam”: 35
} } }
ENGG1810/9810
We plot their grades for each assessment item First, we need representing their name and grade for each item!
We plot their grades for each assessment item First, we need representing their name and grade for each item!
We plot their grades for each assessment item First, we need representing their name and grade for each item!
Emma 20 8 16 42
Spongebob 10 4 14 35
Today’s Lecture
Python Visualisation
We plot their grades for each assessment item First, we need representing their name and grade for each item!
Then, for loop, and visualise with matplotlib
Lists or Tuples
items = ['Weekly', 'LabTest1', 'LabTest2', 'FinalExam']
Multiple lists
Multiple lists
Multiple lists
controls
2 The subplots() function you can
draw multiple plots in one figure
layout
ucancontroltheareaofgraph
x y
nightof
numberabove
nav
ENGG1810/9810
Multiple lists
anav
Y
location
x y
some
ENGG1810/9810
Multiple lists
Multiple lists
axes
The subplots() function you can
draw multiple plots in one figure
key value
I
Multi-dimensional dictionary
ac
intagers got
ENGG1810/9810
key value
Multi-dimensional dictionary
ENGG1810/9810
key value
Multi-dimensional dictionary
Same as page 16
Same as page 19
ENGG1810/9810
key value
Multi-dimensional dictionary
ENGG1810/9810
Today’s Lecture
The mailman on Main Street in Los Angeles tackled the problem in the
fall of 1943 - the third year of World War II.
The mailman on Main Street in Los Angeles tackled the problem in the
fall of 1943 - the third year of World War II.
open(file, mode)
In order to open a file
- file filename
- mode mode
open(file, mode)
In order to open a file
- file filename
- mode mode
read(size)
for reading the content of the file
open(file, mode)
In order to open a file
- file filename
- mode mode
letters
ing read(size)
for reading the content of the file
Python RegEx
Can we remove those punctuations? I want to clean it!
The sub() function replaces the The split() function returns a list where
matches with the text of your choice: the string has been split at each match:
ENGG1810/9810
Replace every
: (colon) or , (comma) or . (full stop)
character with ‘’ (nothing)
[] – a set of characters
ENGG1810/9810
Join function
ENGG1810/9810
Today’s Lecture
- file filename
- mode mode
to append
After appending
ENGG1810/9810
clears a
After overwriting
ENGG1810/9810
Today’s Lecture
It doesnt
exist
ENGG1810/9810
Python has general set of tools for handling such errors called exception handling
NOTE: If nothing goes wrong, the execute block does not run and
program moves to the first line after the try-except block.
ENGG1810/9810
THANKS FOR
WATCHING
Good luck in studying