0% found this document useful (0 votes)
11 views

Lecture12 2

Uploaded by

Rebecca Morris
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lecture12 2

Uploaded by

Rebecca Morris
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

ENGG1810/9810

ENGG1810/9810
Introduction to Engineering Computing
Week 12: Case Study II

Dr. Imdad Ullah


Faculty of Engineering
ENGG1810/9810

COMMONWEALTH OF AUSTRALIA

Copyright Regulations 1969

WARNING

This material has been reproduced and communicated to you by or on behalf of


the University of Sydney pursuant to Part VB of the Copyright Act 1968 (the Act).

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.

Do not remove this notice.


INTRODUCTION
ENGG1810/9810

What will you learn in this course?


Week 1: Introduction to Python

Week 2: Storing Data and Making Decisions Programming


Week 3: Repeating Actions I Basics

Week 4: Repeating Actions II

In Week 11, we learned Week 5: Functions I


1)Time Series Prediction
and 2) String manipulation Week 6: Functions II Functions
Week 7: Libraries and Modules I
and Packages
What do we learn today?
Week 8: Libraries and Modules II

Week 9: Application I

Week 10: Application II Advanced


Week 11: Case Study I
Topics

Week 12: Case Study II

Week 13: Revision and Exam Guide


ENGG1810/9810

Today’s Lecture

Python Case Study for Undergraduate Engineers


Case 3: Basic Simulation
• Simple Sin/Cos Visualisation with ArtistAnimation
• Value representation in the Animation

Case 4: Transport Booking system


• User Interface Generation
• Accessing and Inserting the value
• Slicing and Inserting the value
ENGG1810/9810

Case 3: Basic Simulation

Can we simulate and visualise the


sin/cos value in the graph?
It would be very helpful as a reference.
ENGG1810/9810

Case 3: Basic Simulation


Let me see… What do we need?

How do we simulate and visualise it?


- We can use animation!

Note: There are two main functions that are used to make
animations, FuncAnimation and ArtistAnimation.
Can we simulate and visualise the • FuncAnimation: Makes an animation by repeatedly
sin/cos value in the graph? calling a function func. (learned in Lecture, Lab 6)
It would be very helpful as a reference. • ArtistAnimation: Before calling this function, all
plotting should have taken place and the relevant
artists saved.
ENGG1810/9810

Preliminary Knowledge in Drawing


Before we start, let’s remind ourselves in Lecture 7

Ok! Let’s do some basic


visualisation with animation
ENGG1810/9810

Drawing With ArtistAnimation (1)


Before calling this function, all plotting should have taken place and the relevant artists saved.

Ok! Let’s do some basic


visualisation with animation

https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.ArtistAnimation.html
ENGG1810/9810

Drawing With ArtistAnimation (1)


Before calling this function, all plotting should have taken place and the relevant artists saved.

Ok! Let’s do some basic


visualisation with animation

All plotting should have


taken place
ENGG1810/9810

Drawing With ArtistAnimation (2)


With subplots and drawing the point

Ok! Let’s do some basic


visualisation with animation
ENGG1810/9810

Drawing With ArtistAnimation (2)


With subplots and drawing the point

Ok! Let’s do some basic


visualisation with animation
ENGG1810/9810

Case 3: Basic Simulation


Let me see… What do we need?

How to Visualise the value?

There are two ways to do it.


1. text(): Add the text s to the Axes at location x, y in data
coordinates.
2. annotate(): Annotate the point xy with text.
Can we simulate and visualise the
sin/cos value in the graph?
It would be very helpful as a reference.

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.text.html

ENGG1810/9810

Visualise the Value


Value Representation with text()

How to visualise the value in


the animation
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.annotate.html

ENGG1810/9810

Visualise the Value


Value Representation with annotate()

How to visualise the value in


the animation
ENGG1810/9810

Choose the best visualization with client

Can we simulate and visualise the


sin/cos value in the graph?
It would be very helpful as a reference.

Ok! We are ready now!


Which one do you like the most?
ENGG1810/9810

Today’s Lecture

Python Case Study for Undergraduate Engineers


Case 3: Basic Simulation
• Simple Sin/Cos Visualisation with ArtistAnimation
• Value representation in the Animation

Case 4: Transport Booking system


• User Interface Generation
• Accessing and Inserting the value
• Slicing and Inserting the value
ENGG1810/9810

Case 4: Transport Booking System

Business Class

0
Could you please develop
a program to book the
train seat? 1

Unavailable

Available
ENGG1810/9810

Case 4: Transport Booking System

Business Class
Could you please develop a program
to book the train seat? 0
We hope user can book a seat:
1) by specifying the row and column 1
and 2) that close to the window
2

Unavailable

Available
ENGG1810/9810

Case 4: Transport Booking System


Let me see… What do we need?

1. Initialise the current status of the seat


2. Display the current status
Could you please develop a program 3. Make options for users to select
to book the train seat? 4. Allow users to specify the row and column (and
We hope user can book a seat: check whether the seat is possible)
1) by specifying the row and column 5. Find any available seat that close to window, and
and 2) that close to the window book the seat
ENGG1810/9810

Case 4: Transport Booking System


Ok! We are ready now!
Let’s develop a program

1. Initialise the current status of the seat


2. Display the current status
Could you please develop a program 3. Make options for users to select
to book the train seat? 4. Allow users to specify the row and column (and
We hope user can book a seat: check whether the seat is possible)
1) by specifying the row and column 5. Find any available seat that close to window, and
and 2) that close to the window book the seat
ENGG1810/9810

Initialise and Display the current status


Initialise the empty list

Remember?
The append() method appends
an element to the end of the list
ENGG1810/9810

Initialise and Display the current status


Initialise the empty list Can we use numpy array?

Remember? Of course! Please check


The append() method appends Lecture 7 and Lab 7!
an element to the end of the list

Use for loop to print each element (A list of seats in each row) in new line

We can use this function call, whenever we want to display the current status
ENGG1810/9810

Initialise and Display the current status


Initialise the empty list Can we use numpy array?

Remember? Of course! Please check


The append() method appends Lecture 7 and Lab 7!
an element to the end of the list

Use for loop to print each element (A list of seats in each row) in new line

We can use this function call, whenever we want to display the current status

Exactly Same!
ENGG1810/9810

Case 4: Transport Booking System


Ok! We are ready now!
Let’s develop a program

1. Initialise the current status of the seat


2. Display the current status
Could you please develop a program 3. Make options for users to select
to book the train seat? 4. Allow users to specify the row and column (and
We hope user can book a seat: check whether the seat is possible)
1) by specifying the row and column 5. Find any available seat that close to window, and
and 2) that close to the window book the seat
ENGG1810/9810

Make options for users to select

This data is stored but will not be displayed to users until you print

Function will not be executed until you call it

Printing the Booking System Interface with options


ENGG1810/9810

Make options for users to select

This data is stored but will not be displayed to users until you print

Function will not be executed until you call it

Printing the Booking System Interface with options

Need to create a function for booking a specific seat (using row and column)

Need to create a function for booking a seat that close to the window
ENGG1810/9810

Make options for users to select

This data is stored but will not be displayed to users until you print

Function will not be executed until you call it

Printing the Booking System Interface with options

Need to create a function for booking a specific seat (using row and column)

Need to create a function for booking a seat that close to the window
ENGG1810/9810

Case 4: Transport Booking System


Ok! We are ready now!
Let’s develop a program

1. Initialise the current status of the seat


2. Display the current status
Could you please develop a program 3. Make options for users to select
to book the train seat? 4. Allow users to specify the row and column (and
We hope user can book a seat: check whether the seat is possible)
1) by specifying the row and column 5. Find any available seat that close to window, and
and 2) that close to the window book the seat
ENGG1810/9810

Allow users to specify the row and column

Need to create a function


for booking a specific seat
(using row and column)
ENGG1810/9810

Allow users to specify the row and column

Need to create a function


for booking a specific seat
(using row and column)
ENGG1810/9810

Case 4: Transport Booking System


Ok! We are ready now!
Let’s develop a program

1. Initialise the current status of the seat


2. Display the current status
Could you please develop a program 3. Make options for users to select
to book the train seat? 4. Allow users to specify the row and column (and
We hope user can book a seat: check whether the seat is possible)
1) by specifying the row and column 5. Find any available seat that close to window, and
and 2) that close to the window book the seat
ENGG1810/9810

Find any available seat that close to window

Need to create a function for


booking a seat that close to
the window
ENGG1810/9810

Find any available seat that close to window

Need to create a function for


booking a seat that close to
the window
ENGG1810/9810

THANKS FOR
WATCHING
Good luck in studying

You might also like