RSPP En-Us SG m05 Progintro
RSPP En-Us SG m05 Progintro
Python Fundamentals
Name of presenter
Date
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• Define programming
• Explain the function and features of an integrated development environment (IDE)
• Describe the cycle of programming
A purpose for programming: Automation
Automation refers to any technology that removes human interaction from a system, equipment, or
process.
Scripts are often written to automate labor-intensive tasks and streamline workflows.
Before you automate a process, consider the following:
4
What is a programming language?
5
How is software written?
6
Software is written by using text files
• Some text editors* include features that help programmers write code.
• Examples:
– Microsoft Visual Studio Code
– Sublime Text Software is written by using text files.
– Vi or Vim
– nano
– GNU emacs
– Notepad++ Software is written by using a
computer language.
– TextEdit
7
Software is written by using a computer language
8
Programming language elements
Punctuation Grammar
(operators, (structure,
delimiters) syntax)
Vocabulary
(keywords, identifiers)
9
Integrated development environment (IDE)
An IDE can tell you which Some IDEs work with only
words are spelled incorrectly, one language, such as
Most IDEs will suggest
which phrases are unclear, PyCharm for Python. It will
a fix for the issue.
and syntax that you wrote not show syntax errors for
incorrectly. Java or C# to you.
10
Compilers and interpreters
11
Compiled and interpreted languages
• C/C++ • Python
• Basic • Ruby
• GoLang (the language that • JavaScript
Google developed)
12
13
Software is written iteratively
Write a
little.
Test it.
14
Categorize a value as a data type
What you will learn
16
A data type is the classification of a value that tells the computer how the programmer intends the
data to be interpreted.
Examples:
17
Why must the type of data be tagged?
In memory In code
This is an integer.
0000 0001 1
This is a Boolean.
0000 0001 True
This is an integer.
0100 0001 65
This is a string.
0100 0001 A
18
Activity: Identify Data Instructions
1. For each value, identify the data type:
Types
1. “The Martian”
2. 1.618
3. 10082L
4. False
5. “True”
19
20
Assigning a variable to a value
Python VB.NET
isCoder = True daysOnJob = 1
F# Pascal
daysOnJob <- 1 isCoder := true
21
Assigning a data type to a variable
• Some languages expect the data type to be included when first using the variable.
Objective C
int daysOnJob = 1
Java
boolean isCoder = true
22
Assigning a data type to a variable, continued
• Some languages infer the data type based on the value that is assigned.
Python
count = 10
Swift
var daysOnJob = 1
TypeScript
let isCoder = true
23
Activity: Represent letters as numbers
American Standards Association for Information Interchange (ASCII) is a system that associates encoding
characters into computers.
Use the ASCII table at ASCII Table to decipher the following message:
Space
109 – 121 – 32 – 99 – 97 – 114 – 32 – 107 – 101 – 121 – 115 – 63
24
Activity: Represent letters as numbers
American Standards Association for Information Interchange (ASCII) is a system that associates encoding
characters into computers.
Use the ASCII table at ASCII Table to decipher the following message:
H a v e y o u s e e n
Space
109 – 121 – 32 – 99 – 97 – 114 – 32 – 107 – 101 – 121 – 115 – 63
m y c a r k e y s ?
25
27
All modern programming languages have a way to create composite data types.
28
Composite data type example: Movie
String
+ +
Name Year Flag
29
Composite data type 1
IsReadOnly Length
30
Composite data type 2
31
Composite data type 3
32
Functions
Functions
Functions do something useful.
Functions can return a value (to be stored in a variable). • The following slides provide
examples of each of these
Functions can return a value based on input values. attributes.
latitude
Functions can accept many values as input.
longitude
speed
Or, a developer can create a composite data type.
heading
Composite data types can be returned. verticalSpeed
windSpeed
Composite data types can be in an array. windDirection
41
Functions, continued
Functions do something useful.
latitude
Functions can accept many values as input.
longitude
Or, a developer can create a composite data type. speed
heading
Composite data types can be returned. verticalSpeed
windSpeed
Composite data types can be in an array. windDirection
42
Collections
A collection groups multiple values in a single variable. Different types of collections are available:
Deque
Queue (double-ended Hashes Dictionaries
queue)
43
Example collection: Array
The table shows a basic array of ages. Each age is Slot Data Type Value
assigned a slot, is of the same data type, and is adjacent
to the previous age and the next age in memory. 0 Integer 87
1 Integer 10
• The first slot is almost always 0 in every language. 2 Integer 2
• Notice that the values do not need to be in any order.
3 Integer 46
4 Integer 22
5 Integer 19
6 Integer 66
44
Python collection example: List
45
A Python list is ordered because each new item is added to the end of the list.
Follow the execution path of a program
What you will learn
47
48
Conditionals
• All programming languages have a way to choose an either-or path in the code.
49
Example from Python
if(name == ‘Juan'):
bonus = 300
else:
50
Switches
• Most programming languages have a way to conveniently handle multiple possible cases of a value.
switch(sign):
case "Stop": pressBreak()
case "Merge": accelerate()
case "Exit": decelerate()
default: ignore()
51
Loops
52
Example from Python
for(employee in employees):
employee.bonus = employee.salary * 0.1;
53
Version control
What you will learn
55
A version control system is software that tracks versions of your code and documents
as you update them.
Version control can be done locally on your computer or by using a website that is
dedicated to saving these versions.
56
Advantages of version control
Error tracking
Ease of access to
Security
project changes
Version control
57
Utilizing cloud infrastructure
58
Version control tools
Mercurial GitHub
Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.
59
Git
Install the Git tools
61
Git, continued
62
Git, continued
If the commit message did not work, you most likely saw a message that said Please tell me who you
are in the terminal.
14. To clear this message, in the terminal, enter the following two commands :
– git config –global user.email “<[email protected]>”
» Replace <[email protected]> with an email address that you actually own and want to
use for this course.
» The rest of the command is entered exactly, including the quotation marks (“ “).
– git config –global user.name “<Your name>”
» Replace <Your name> with a user name that you want to use for this course. Make it
unique.
» The rest of the command is entered exactly, including the quotation marks.
63
Git, continued
15. After you are finished, enter git commit -m “Initial commit” again, followed by git status to
confirm that Git is not tracking any new changes.
64
GitHub
GitHub is a repository hosting service. It uses repositories and the same commands as the terminal.
To prepare for the lab, create a GitHub account on GitHub, if you don’t already have one.
Sites like GitHub are also a good way to exhibit your code to developers and potential employers.
65
Checkpoint questions
What is an IDE?
66
Answers:
1. From the lesson, it was shown that automation is one of the uses of
programming.
2. Programs are written in text files.
3. An IDE is an integrated development environment that helps with writing code.
4. Whole numbers are typically stored as integers.
5. Functions enable developers to create discrete sections of code that can be called
by using the function’s name. The resulting function is then available to the rest of
the source code.
6. Git.
• Programming is a way to automate processes.
Key takeaways
• Programming languages specify a way to
communicate directions to a computer.
• Software is written into a text file by using a
programming language, which is either interpreted
or compiled when it is run.
• Data is typed so that the interpreter or compiler
knows whether it is a string, integer, Boolean, or
other data type.
• A composite data type stores different types of data
in a single variable.
• Functions are collections of instructions that can be
called repeatedly in a program.
• Version control manages changes to computer
programs, documents, or other collections of
information.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
67