SlideShare a Scribd company logo
1 of 83
INTRODUCTION
About me
● My name: Nguyễn Đăng Bảo Long
● Current study: University of Engineering
and Technology - VNU
● Main subject: Cloud Computing,
Networking, Information Technology
● Email: baolong.a1yh@gmail.com
Get to know each other
● What do you do?
● How many of you have heard about
programming?
● Have done some programming?
Please share it
This course rule
1. Use the Google search as much as possible
2. Please ask me as much as possible (feel free to interrupt me if needed)
3. Repeat what I do as much as you can
4. You are allowed to use mobile phone, but use it wisely
Course overview
Course objective
After this course, you will be able to:
● Write your own applications
● Create a simple game from scratch
● Go on studying deeper in Python
Desktop app vs. Mobile app
There were about 30
million lines of code in the
Mac version of Microsoft
Office (the whole suite) in
2006.
Let’s see how many kind of desktop app do you know
You will have 2 minutes to write down all kind of
desktop app you know.
Let’s see who get the most number.
A process to make an app
Phase 1: Idea
● An idea is given by a customer or a
leader of a team
● There will be a draft where the app’s
UI is sketched, the app’s functions is
noted
Phase 2: Analysis & Design
● After all the requirements have been
clarified, the devs are gonna choose
which technology will be used.
● Then the dev team will focus on
designing the:
○ UI
○ Components in the App (Login part, Paying
part,...)
○ Back-end server, system
○ ...
Phase 3: Develop & Test
● At this phase, the dev team is actually
do the coding, building the app part by
part.
● Each part can be accomplished by a
small team.
● There are some peoples, called
“testers”, coming in to find any error in
the app.
● The dev team then try to fix those
errors, or “debug”
Phase 4: Deploy
● Bring up the app to the marketplace,
where the user can use it
● At this stage, app will need to be
advertised by the marketing team, in
order to make it popular
Phase 5: Maintenance & Update
● After releasing, app shouldn’t be neglected.
● The team should continuously update it,
improve it, keep making new functions.
What are we going to do in this course?
● We involve in the developing part
● Assume that all the ideas, requirements is exists, we just jump right in
building it.
Technology (programming language) we use?
There are about 700 programming languages - Wikipedia
We are gonna use Python
Why are we using it?
● Easy to learn
● Convenient to use
● Short to write code
● But:
○ Be careful with its syntax, 1 whitespace character
can makes the difference
Python’s utility
● Small-to-big desktop apps
● AI, Machine Learning
● Web apps
● Mobile apps
● Data Analysis, tools,...
App Demonstration
PART 1: PYTHON BASICS
(Also coding basics)
In this part:
1. Install the prerequisites
2. Basic structure of a program
3. The output
○ To screen/file
4. The input
○ Variable
○ Data type
○ Operator
5. Execute part of a program
○ Logic
○ Loop
○ List
○ Function and Module
Install the prerequisites
About Python
● Python is an interpreter
○ It’s a program which converts each of your line code, one by one, to a language which the
computers can understand and execute it
Python version
There are 2 version:
● Python 2
● Python 3 (currently 3.8.1)
We will use Python 3, since it’s the latest
update
Python download and install (Windows)
● Go to the page https://www.python.org/downloads/windows/ and download
the latest version of Python 3
● Install it
● Set the environment variable for python (it already done by default)
● Check with cmd by typing python
Python download and install (Linux/Ubuntu)
● Open the Terminal
● Run the following command:
○ sudo apt install python3
○ sudo apt install python3-pip
● Check with command python3
Python download and install (Mac OSX)
● Python 2 is installed on Mac by default, but we recommend using Python 3
● Go to the page https://www.python.org/downloads/ and download the latest
version of Python 3
● Install it
● Set the environment variable for python (it already done by default)
● Check with terminal by typing python3
Python IDE
Pycharm Visual Studio Code
Text Editor
Python exploring
Just put “python” before
everything you want to
search about Python
Alright, now you are ready to go!
Program “anatomy”
Every app (or program) has 3 components:
INPUT EXECUTE OUTPUT
Example
Let’s have a simple example, at the coffee
shop
● There are many choices on the menu for
which the customer can orders.
● Each time, the customers will select 1 or
more options for them and their friends.
● The program is to takes the orders,
calculates the price, and prints out the
bill.
Example analysis
Input Execute Output
Data about coffee: The menu, the
price for each type of drink.
Customer data: Which drinks do
the customers order.
Maps each drink to its price.
Sums up all the prices.
Displays on the screen for the
customers.
Prints out the bill.
So, how are we going to implement all of the above?
Let’s start with the easiest part first
INPUT EXECUTE OUTPUT
The “print” Command
● Display something on your screen
Type these lines in your IDE
print(“Hello World”)
print(“””
You can prints out every thing here
It will output with the exact format
“””)
How about writing to a file?
You can use the “with open” statement, like this:
with open(“aFile.txt”, “w”) as file:
file.write(“Some random words in here”)
Oops, be careful with this indent
with open(“aFile.txt”, “w”) as file:
file.write(“Some random words in here”)
This indent must be exactly 4 whitespace characters.
Let’s do a quick exercise
Your job is to draw a mighty sword with any
characters in a .doc file
Okay, let’s move to the second part
INPUT EXECUTE OUTPUT
Same as output, there are 2 ways doing this
Input from keyboard
You can prompt user with the input command, like below:
input(“Prompting: “)
input(“>>> “)
But, where do the inputs go?
● Do they just disappear???
○ Yes and No
● We need to store them somewhere for future use, and that “somewhere” is
called variables.
Variables
Variables are like a closet. You can store any
thing you want inside it, and take them out at
any time you want
How to use it?
The syntax to define a variable is
variable_name = <something you want to store>
For example:
name = input(“Input your name here: “)
print(name)
Other ways using variables
● With number: (You can do the calculating with these variables)
age = 16
sum = 2 + 3 ( = 5 )
product = 5 * 6 ( = 30)
quotient = 21 / 4 ( = 5.25)
● With boolean value:
is_a_girl = True
is_from_Japan = False
Be careful using it !!!
● It just works one way
○ This is good: number = 5
○ This is bad: 5 = number
○ This is also bad: number1 = number2 = 5
● Be careful naming the variables:
○ You can use lowercase, uppercase, number, underscore: downUp, UpDown, down_up,
up1_down2
○ Don’t put number at the beginning: 1_variable
○ Don’t use special character: not_this!,
or_this?,...
○ Don’t use word that is used in Python syntax: if, else, for,...
Compare 2 variables
bigger_number = 10
smaller_number = 7
compare = bigger_number > smaller_number (True)
compare = bigger_number < smaller_number (False)
Compare 2 variables
● What if we want to know if 2 variables has the same value?
● We use 2 operator: == and !=
○ compare = bigger_number == smaller_number ( ? )
○ compare = bigger_number != smaller_number ( ? )
Variable data type
● What will happen if we compare 2 variable that has different data type? (E.g:
a number and a character string)
○ number = 10
○ word = “5”
○ compare = number > word
○ print(compare) ( ? )
● We should convert them to the same data type and then do some operation
on them
○ number2 = int(word)
○ compare = number > number2
○ print(compare)
Data Type Conversion
● Four data type you should remember for now:
int, float, str, bool
● Python syntax to switch between them:
converted_value = <convert_data_type>(initial_value)
● Example:
a_number = 3
a_string = str(a_number)
print(a_string)
● Python syntax to check the variable type:
type(variable)
An exercise to remember what we have learn so far
● A program that ask for the user’s name and Year of Birth
● Prints out a greeting with information like the following:
Tips: There is something missing in the “print” command, Google search for it!
Okay, that’s all you need to know about input and
output
Let’s dive into this part
INPUT EXECUTE OUTPUT
Go back to the earlier example: The coffee shop
How did the computer work after it has received the order?
● Remember the order
● For each drink in the customer’s order:
○ Look for it in the data (menu)
○ Add the associate price to the total cost in the bill
● Show the total price to the customer and
the cashier
We divide that process into smaller pieces
Input
Assign the
order to
variables
Get the name
of the drink
Get the name
of the drink in
the menu
If 2 names
are the same
Add the price
to the total
cost
Show the
cost
For each variable
For each drink in the menu
True
How to solve this piece of problem
How to solve this piece of problem
● Remember how to compare 2 variables?
● How to direct the program in each case?
Same and not same?
If 2 names are
the same
Branching statements
If … else....
Python syntax:
if <conditional expression>:
#Do something if the expression is
true
else:
#Do something if the expression is
false
Also, this is call a comment
Comment line start with the # character
Computers will ignore every comment line
In
Condition
Command
block 1
Command
block 2
Out
False
True
Example
Write a program that ask for the user’s age, then tell them that they are:
● Young: if age < 20
● Old: if age > 20
Next level: we use something call elif
● Baby: if age < 5
● Young: if 5 < age < 18
● Grow up: if 18 < age < 60
● Old: if age > 60
Back to our previous example
Espresso
$5
Macchiato
$7
Latte
$8
Cappuccino
$10
1 latte please!
Practice makes perfect...
Create a program that:
● Require user’s input for weight and height
● Calculate the body mass index (BMI)
● Prints out the result to the screen (and may be some advice :p)
Another problem
● How to print out 1000 lines, each
line has a word “Hello” in it?
● How about 1000*1000 lines?
print(“Hello”)
print(“Hello”)
print(“Hello”)
print(“Hello”)
print(“Hello”)
print(“Hello”)
print(“Hello”)
print(“Hello”)
print(“Hello”)
.
.
.
.
.
.
.
.
.
.
print(“Hello”)
print(“””
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
.
.
.
.
.
.
.
.
.
.
Hello”””)
Loop statements
While
● To solve that problem, we use loop syntax
● In Python, we have 2 syntax for this:
while command
○ while <conditional expression>:
# Do some loop command here
In
Condition
Command
block
Out
False
True
For… in...
● To solve that problem, we use loop syntax
● In Python, we have 2 syntax for this:
for command
○ for i in range(0, <number of iterations>):
# Do some loop command here
● range(start, stop, step)
● Why do we need to start from 0?
In
i < num
Command
block
Out
False
True
Example
A program that prints out a table that:
● Compare between 2 types of temperature
measurement units: Celsius and Fahrenheit
● Start from 0 degree C to 100 degree C
● Each line is 10 degrees difference
● Use the following formula
Loop benefits
● Repeatedly does the same job, so you don’t have to write the same code for
many lines
● Makes the source code of your program more readable
Keep practicing
Build a program that:
● User inputs 1 number n (1<n<1000)
● If n is out of the above range, prints out
the error
● Else, prints out the sum of all the number
from 1 to n
● Please don’t use this formula, use loop
statements instead
Comeback to our previous example
Input
Assign the
order to
variables
Get the name
of the drink
Get the name
of the drink in
the menu
If 2 names
are the same
Add the price
to the total
cost
Show the
cost
For each variable
For each drink in the menu
True
How to store a huge number of value wisely?
● How about this piece of problem?
● What if the customer order 10 or 20 different
drinks?
○ Store them in 20 variables is not a good idea
○ Naming each variable will become nightmare if the number
of them increase
● Is there any another way to store this big number
of value?
Assign the
order to
variables
List
Use to store values in an effective, organized way
John
25
john@example.com
Name
Age
Email
John 25
john@example.com
John’s information
22/2/1995
DOB
22/2/1995
How to use List
● Define a List:
john_info = [“John”, 25, “22/2/1995”, “john@example.com”]
● How to use an element in the list:
Try this:
print(john_info[2])
How index works in a List?
john_info = [“John”, 25, “22/2/1995”, “john@example.com”]
0 1 2 3
Actually, the “for” loop and “list” make the perfect match
● You can use for statement to get the values out of a list
● For each value in the list, we do something with it
john_info = [“John”, 25, “22/2/1995”,
“john@example.com”]
for info in john_info:
print(info)
Let’s check back the previous example
● Seems like we have everything we need to do all of this
● Let me show you how to implement all of this at one
Input
Assign the
order to
variables
Get the
name of the
drink
Get the
name of the
drink in the
menu
If 2 names
are the same
Add the price
to the total
cost
Show the
cost
For each variable
For each drink in the menu
True
The last skill: Function and module
● Why do we need this?
○ Functions are like the blueprint of codes
○ You can reuse it as many time as you want without retyping
the code
○ Make the program’s code more readable
● Syntax:
def function_name(input_to_function):
# Do something here
● Modules are like the collection of functions, you
can share with others developer or keep it for later
use
Prepare for next week
● Using pip3 to download and install pyqt5 tools
The work you can do at home
● At the end of each session, you will be given 1 problem which you can do at
home.
● The result of your work will be assessed based on a variety of criteria.
● Each criteria passed, you will score some points.
● Candidates who get highest scores will have some gifts.
Join this Google classroom: hydfs5h
Books you can read at home
● Learn Python The Hard Way - Zed Shaw
(recommended!)
● Python rất là cơ bản - Võ Duy Tuấn
● Core Python Applications Programming -
Wesley J Chun

More Related Content

Similar to Application development with Python - Desktop application

Blueprints: Introduction to Python programming
Blueprints: Introduction to Python programmingBlueprints: Introduction to Python programming
Blueprints: Introduction to Python programmingBhalaji Nagarajan
 
Mastering python lesson2
Mastering python lesson2Mastering python lesson2
Mastering python lesson2Ruth Marvin
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonmckennadglyn
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsRuth Marvin
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptxHaythamBarakeh1
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonRanjith kumar
 
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON Nandakumar P
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basicSara Samol
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of pythonBijuAugustian
 
python presentation
python presentationpython presentation
python presentationVaibhavMawal
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfMMRF2
 
Python Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowPython Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowRanel Padon
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it securityCESAR A. RUIZ C
 
Using Python inside Programming Without Coding Technology (PWCT) Environment
Using Python inside Programming Without Coding Technology (PWCT) EnvironmentUsing Python inside Programming Without Coding Technology (PWCT) Environment
Using Python inside Programming Without Coding Technology (PWCT) EnvironmentMahmoud Samir Fayed
 
Getting big without getting fat, in perl
Getting big without getting fat, in perlGetting big without getting fat, in perl
Getting big without getting fat, in perlDean Hamstead
 

Similar to Application development with Python - Desktop application (20)

Blueprints: Introduction to Python programming
Blueprints: Introduction to Python programmingBlueprints: Introduction to Python programming
Blueprints: Introduction to Python programming
 
ForLoops.pptx
ForLoops.pptxForLoops.pptx
ForLoops.pptx
 
Mastering python lesson2
Mastering python lesson2Mastering python lesson2
Mastering python lesson2
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of python
 
Introducing Small Basic.pdf
Introducing Small Basic.pdfIntroducing Small Basic.pdf
Introducing Small Basic.pdf
 
python presentation
python presentationpython presentation
python presentation
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdf
 
Python Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowPython Programming - III. Controlling the Flow
Python Programming - III. Controlling the Flow
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it security
 
Using Python inside Programming Without Coding Technology (PWCT) Environment
Using Python inside Programming Without Coding Technology (PWCT) EnvironmentUsing Python inside Programming Without Coding Technology (PWCT) Environment
Using Python inside Programming Without Coding Technology (PWCT) Environment
 
Getting big without getting fat, in perl
Getting big without getting fat, in perlGetting big without getting fat, in perl
Getting big without getting fat, in perl
 
python-handbook.pdf
python-handbook.pdfpython-handbook.pdf
python-handbook.pdf
 

Recently uploaded

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 

Recently uploaded (20)

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 

Application development with Python - Desktop application

  • 1.
  • 3. About me ● My name: Nguyễn Đăng Bảo Long ● Current study: University of Engineering and Technology - VNU ● Main subject: Cloud Computing, Networking, Information Technology ● Email: baolong.a1yh@gmail.com
  • 4. Get to know each other ● What do you do? ● How many of you have heard about programming? ● Have done some programming? Please share it
  • 5. This course rule 1. Use the Google search as much as possible 2. Please ask me as much as possible (feel free to interrupt me if needed) 3. Repeat what I do as much as you can 4. You are allowed to use mobile phone, but use it wisely
  • 7. Course objective After this course, you will be able to: ● Write your own applications ● Create a simple game from scratch ● Go on studying deeper in Python
  • 8. Desktop app vs. Mobile app There were about 30 million lines of code in the Mac version of Microsoft Office (the whole suite) in 2006.
  • 9. Let’s see how many kind of desktop app do you know You will have 2 minutes to write down all kind of desktop app you know. Let’s see who get the most number.
  • 10. A process to make an app
  • 11. Phase 1: Idea ● An idea is given by a customer or a leader of a team ● There will be a draft where the app’s UI is sketched, the app’s functions is noted
  • 12. Phase 2: Analysis & Design ● After all the requirements have been clarified, the devs are gonna choose which technology will be used. ● Then the dev team will focus on designing the: ○ UI ○ Components in the App (Login part, Paying part,...) ○ Back-end server, system ○ ...
  • 13. Phase 3: Develop & Test ● At this phase, the dev team is actually do the coding, building the app part by part. ● Each part can be accomplished by a small team. ● There are some peoples, called “testers”, coming in to find any error in the app. ● The dev team then try to fix those errors, or “debug”
  • 14. Phase 4: Deploy ● Bring up the app to the marketplace, where the user can use it ● At this stage, app will need to be advertised by the marketing team, in order to make it popular
  • 15. Phase 5: Maintenance & Update ● After releasing, app shouldn’t be neglected. ● The team should continuously update it, improve it, keep making new functions.
  • 16. What are we going to do in this course? ● We involve in the developing part ● Assume that all the ideas, requirements is exists, we just jump right in building it.
  • 18. There are about 700 programming languages - Wikipedia
  • 19. We are gonna use Python
  • 20. Why are we using it? ● Easy to learn ● Convenient to use ● Short to write code ● But: ○ Be careful with its syntax, 1 whitespace character can makes the difference
  • 21. Python’s utility ● Small-to-big desktop apps ● AI, Machine Learning ● Web apps ● Mobile apps ● Data Analysis, tools,...
  • 23. PART 1: PYTHON BASICS (Also coding basics)
  • 24. In this part: 1. Install the prerequisites 2. Basic structure of a program 3. The output ○ To screen/file 4. The input ○ Variable ○ Data type ○ Operator 5. Execute part of a program ○ Logic ○ Loop ○ List ○ Function and Module
  • 26. About Python ● Python is an interpreter ○ It’s a program which converts each of your line code, one by one, to a language which the computers can understand and execute it
  • 27. Python version There are 2 version: ● Python 2 ● Python 3 (currently 3.8.1) We will use Python 3, since it’s the latest update
  • 28. Python download and install (Windows) ● Go to the page https://www.python.org/downloads/windows/ and download the latest version of Python 3 ● Install it ● Set the environment variable for python (it already done by default) ● Check with cmd by typing python
  • 29. Python download and install (Linux/Ubuntu) ● Open the Terminal ● Run the following command: ○ sudo apt install python3 ○ sudo apt install python3-pip ● Check with command python3
  • 30. Python download and install (Mac OSX) ● Python 2 is installed on Mac by default, but we recommend using Python 3 ● Go to the page https://www.python.org/downloads/ and download the latest version of Python 3 ● Install it ● Set the environment variable for python (it already done by default) ● Check with terminal by typing python3
  • 31. Python IDE Pycharm Visual Studio Code Text Editor
  • 32. Python exploring Just put “python” before everything you want to search about Python
  • 33. Alright, now you are ready to go!
  • 34. Program “anatomy” Every app (or program) has 3 components: INPUT EXECUTE OUTPUT
  • 35. Example Let’s have a simple example, at the coffee shop ● There are many choices on the menu for which the customer can orders. ● Each time, the customers will select 1 or more options for them and their friends. ● The program is to takes the orders, calculates the price, and prints out the bill.
  • 36. Example analysis Input Execute Output Data about coffee: The menu, the price for each type of drink. Customer data: Which drinks do the customers order. Maps each drink to its price. Sums up all the prices. Displays on the screen for the customers. Prints out the bill.
  • 37. So, how are we going to implement all of the above?
  • 38. Let’s start with the easiest part first INPUT EXECUTE OUTPUT
  • 39. The “print” Command ● Display something on your screen Type these lines in your IDE print(“Hello World”) print(“”” You can prints out every thing here It will output with the exact format “””)
  • 40. How about writing to a file? You can use the “with open” statement, like this: with open(“aFile.txt”, “w”) as file: file.write(“Some random words in here”)
  • 41. Oops, be careful with this indent with open(“aFile.txt”, “w”) as file: file.write(“Some random words in here”) This indent must be exactly 4 whitespace characters.
  • 42. Let’s do a quick exercise Your job is to draw a mighty sword with any characters in a .doc file
  • 43. Okay, let’s move to the second part INPUT EXECUTE OUTPUT
  • 44. Same as output, there are 2 ways doing this
  • 45. Input from keyboard You can prompt user with the input command, like below: input(“Prompting: “) input(“>>> “)
  • 46. But, where do the inputs go? ● Do they just disappear??? ○ Yes and No ● We need to store them somewhere for future use, and that “somewhere” is called variables.
  • 47. Variables Variables are like a closet. You can store any thing you want inside it, and take them out at any time you want
  • 48. How to use it? The syntax to define a variable is variable_name = <something you want to store> For example: name = input(“Input your name here: “) print(name)
  • 49. Other ways using variables ● With number: (You can do the calculating with these variables) age = 16 sum = 2 + 3 ( = 5 ) product = 5 * 6 ( = 30) quotient = 21 / 4 ( = 5.25) ● With boolean value: is_a_girl = True is_from_Japan = False
  • 50. Be careful using it !!! ● It just works one way ○ This is good: number = 5 ○ This is bad: 5 = number ○ This is also bad: number1 = number2 = 5 ● Be careful naming the variables: ○ You can use lowercase, uppercase, number, underscore: downUp, UpDown, down_up, up1_down2 ○ Don’t put number at the beginning: 1_variable ○ Don’t use special character: not_this!, or_this?,... ○ Don’t use word that is used in Python syntax: if, else, for,...
  • 51. Compare 2 variables bigger_number = 10 smaller_number = 7 compare = bigger_number > smaller_number (True) compare = bigger_number < smaller_number (False)
  • 52. Compare 2 variables ● What if we want to know if 2 variables has the same value? ● We use 2 operator: == and != ○ compare = bigger_number == smaller_number ( ? ) ○ compare = bigger_number != smaller_number ( ? )
  • 53. Variable data type ● What will happen if we compare 2 variable that has different data type? (E.g: a number and a character string) ○ number = 10 ○ word = “5” ○ compare = number > word ○ print(compare) ( ? ) ● We should convert them to the same data type and then do some operation on them ○ number2 = int(word) ○ compare = number > number2 ○ print(compare)
  • 54. Data Type Conversion ● Four data type you should remember for now: int, float, str, bool ● Python syntax to switch between them: converted_value = <convert_data_type>(initial_value) ● Example: a_number = 3 a_string = str(a_number) print(a_string) ● Python syntax to check the variable type: type(variable)
  • 55. An exercise to remember what we have learn so far ● A program that ask for the user’s name and Year of Birth ● Prints out a greeting with information like the following: Tips: There is something missing in the “print” command, Google search for it!
  • 56. Okay, that’s all you need to know about input and output
  • 57. Let’s dive into this part INPUT EXECUTE OUTPUT
  • 58. Go back to the earlier example: The coffee shop How did the computer work after it has received the order? ● Remember the order ● For each drink in the customer’s order: ○ Look for it in the data (menu) ○ Add the associate price to the total cost in the bill ● Show the total price to the customer and the cashier
  • 59. We divide that process into smaller pieces Input Assign the order to variables Get the name of the drink Get the name of the drink in the menu If 2 names are the same Add the price to the total cost Show the cost For each variable For each drink in the menu True How to solve this piece of problem
  • 60. How to solve this piece of problem ● Remember how to compare 2 variables? ● How to direct the program in each case? Same and not same? If 2 names are the same
  • 62. If … else.... Python syntax: if <conditional expression>: #Do something if the expression is true else: #Do something if the expression is false Also, this is call a comment Comment line start with the # character Computers will ignore every comment line In Condition Command block 1 Command block 2 Out False True
  • 63. Example Write a program that ask for the user’s age, then tell them that they are: ● Young: if age < 20 ● Old: if age > 20 Next level: we use something call elif ● Baby: if age < 5 ● Young: if 5 < age < 18 ● Grow up: if 18 < age < 60 ● Old: if age > 60
  • 64. Back to our previous example Espresso $5 Macchiato $7 Latte $8 Cappuccino $10 1 latte please!
  • 65. Practice makes perfect... Create a program that: ● Require user’s input for weight and height ● Calculate the body mass index (BMI) ● Prints out the result to the screen (and may be some advice :p)
  • 66. Another problem ● How to print out 1000 lines, each line has a word “Hello” in it? ● How about 1000*1000 lines? print(“Hello”) print(“Hello”) print(“Hello”) print(“Hello”) print(“Hello”) print(“Hello”) print(“Hello”) print(“Hello”) print(“Hello”) . . . . . . . . . . print(“Hello”) print(“”” Hello Hello Hello Hello Hello Hello Hello Hello . . . . . . . . . . Hello”””)
  • 68. While ● To solve that problem, we use loop syntax ● In Python, we have 2 syntax for this: while command ○ while <conditional expression>: # Do some loop command here In Condition Command block Out False True
  • 69. For… in... ● To solve that problem, we use loop syntax ● In Python, we have 2 syntax for this: for command ○ for i in range(0, <number of iterations>): # Do some loop command here ● range(start, stop, step) ● Why do we need to start from 0? In i < num Command block Out False True
  • 70. Example A program that prints out a table that: ● Compare between 2 types of temperature measurement units: Celsius and Fahrenheit ● Start from 0 degree C to 100 degree C ● Each line is 10 degrees difference ● Use the following formula
  • 71. Loop benefits ● Repeatedly does the same job, so you don’t have to write the same code for many lines ● Makes the source code of your program more readable
  • 72. Keep practicing Build a program that: ● User inputs 1 number n (1<n<1000) ● If n is out of the above range, prints out the error ● Else, prints out the sum of all the number from 1 to n ● Please don’t use this formula, use loop statements instead
  • 73. Comeback to our previous example Input Assign the order to variables Get the name of the drink Get the name of the drink in the menu If 2 names are the same Add the price to the total cost Show the cost For each variable For each drink in the menu True
  • 74. How to store a huge number of value wisely? ● How about this piece of problem? ● What if the customer order 10 or 20 different drinks? ○ Store them in 20 variables is not a good idea ○ Naming each variable will become nightmare if the number of them increase ● Is there any another way to store this big number of value? Assign the order to variables
  • 75. List Use to store values in an effective, organized way John 25 john@example.com Name Age Email John 25 john@example.com John’s information 22/2/1995 DOB 22/2/1995
  • 76. How to use List ● Define a List: john_info = [“John”, 25, “22/2/1995”, “john@example.com”] ● How to use an element in the list: Try this: print(john_info[2])
  • 77. How index works in a List? john_info = [“John”, 25, “22/2/1995”, “john@example.com”] 0 1 2 3
  • 78. Actually, the “for” loop and “list” make the perfect match ● You can use for statement to get the values out of a list ● For each value in the list, we do something with it john_info = [“John”, 25, “22/2/1995”, “john@example.com”] for info in john_info: print(info)
  • 79. Let’s check back the previous example ● Seems like we have everything we need to do all of this ● Let me show you how to implement all of this at one Input Assign the order to variables Get the name of the drink Get the name of the drink in the menu If 2 names are the same Add the price to the total cost Show the cost For each variable For each drink in the menu True
  • 80. The last skill: Function and module ● Why do we need this? ○ Functions are like the blueprint of codes ○ You can reuse it as many time as you want without retyping the code ○ Make the program’s code more readable ● Syntax: def function_name(input_to_function): # Do something here ● Modules are like the collection of functions, you can share with others developer or keep it for later use
  • 81. Prepare for next week ● Using pip3 to download and install pyqt5 tools
  • 82. The work you can do at home ● At the end of each session, you will be given 1 problem which you can do at home. ● The result of your work will be assessed based on a variety of criteria. ● Each criteria passed, you will score some points. ● Candidates who get highest scores will have some gifts. Join this Google classroom: hydfs5h
  • 83. Books you can read at home ● Learn Python The Hard Way - Zed Shaw (recommended!) ● Python rất là cơ bản - Võ Duy Tuấn ● Core Python Applications Programming - Wesley J Chun

Editor's Notes

  1. I’m not very good in English so might talk Vietnamese sometimes
  2. How many of you have heard about programming Have been programming
  3. 2. Hãy hỏi nhiều vì có thể tiếng Anh ko rõ thì sẽ nói tiếng Việt hoặc mình có thể coi mặc định là đã đúng nên khó cho người mới
  4. https://www.visualcapitalist.com/millions-lines-of-code/
  5. https://www.visualcapitalist.com/millions-lines-of-code/ Nghĩ xem làm như nào họ tạo được những app đó? Các bước
  6. There are many way to understand this process but in conclusion, it mainly contains the following https://lvivity.com/5-phases-mobile-app-development-lifecycle
  7. Easy to learn: Even 10 year-old kid can acquire it There are hundred, may be thousand of document about it out there, on the internet Convenient to use: NASA scientis use it to launch rocket There are various tools which can help us develop our apps, tools here mean library, framework... Short to write code: We can compare the same purpose app with other programming, if C/C++ will need 30 line to work, Python only need about 5 or 6
  8. Is your Python all work?