RSPP En-Us SG M05 Pythonintro
RSPP En-Us SG M05 Pythonintro
Python Fundamentals
Name of presenter
Date
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
4
Why Python?
Python can
support object-
Python syntax is
oriented,
simple when it is
structural, and
compared to
functional
other languages.
programming
styles.
5
Why Python? continued
Another reason to use Python is that it works across platforms. It works on macOS, Linux, Microsoft
Windows, and other platforms.
GNU/Linux
6
Where can you write Python?
Python can be written in any text editor if you have the interpreter also installed. Many developers use
special programs that are called integrated development environments (IDEs). IDEs help with finding
syntax and exception errors.
Some examples of programs that are used to write Python code include:
Microsoft
Python(x,y AWS Cloud9 Visual Studio Eclipse
) Code
7
Integrated development environment
8
Using an IDE: Syntax highlighting
9
Using an IDE: Code completion
10
Using an IDE: Debugging
11
AWS Cloud9: Cloud-based IDE
Start projects quickly and Code together in real time. Build serverless
code with only a browser. applications with ease.
12
AWS Cloud9 is a cloud-based IDE that lets you write, run, and debug your code with a
browser. It combines the rich code editing features of an IDE with access to a full
Linux server for running and storing code. Some of the editing features include code
completion, hinting, and step-through debugging.
AWS Cloud9 provides a few key benefits:
• Start projects quickly and code with only a web browser. All that you need is an
AWS account. You can log into the AWS Management Console, create an AWS
Cloud9 environment, and start using it in your browser.
• Code together in real time. For example, you don’t need to commit your changes
to Git and then ask a colleague to look at the changes on their machine. AWS
Cloud9 enables you to code together in real time through the AWS Cloud9
interface. AWS Cloud9 provides real-time feedback so you can see what your
colleague is typing as they are typing it and give them feedback.
• Build serverless applications with ease. For example, you can edit and debug AWS
Lambda functions locally. You don’t need to upload your code to the Lambda
console for testing and debugging.
For more information about AWS Cloud9, see the product page: AWS Cloud9
AWS Cloud9 development, runtime, and version control
Development Runtime Version control
environment environment system
14
AWS Cloud9: One IDE, many languages
15
With AWS Cloud9, you can use many runtime environments that enable you to build
and run your code.
Running Python applications
However, what if you must run your code or application? For example:
1. Make it available to users around the world
2. Handle millions of users
16
AWS Lambda
17
You will learn more about AWS Lambda later in the course.
18
This example illustrates the use of Lambda for an image recognition application, and
demonstrates how it works.
First, the users capture an image for their property by using an app on their mobile
phone. The mobile app then uploads the new image to Amazon Simple Storage
Service (Amazon S3). Adding this image to Amazon S3 triggers a Lambda function and
calls Amazon Rekognition. Amazon Rekognition can identify objects, people, text,
scenes, and activities. It provides highly accurate facial analysis and recognition.
Lambda retrieves the image from Amazon S3 and returns labels for the property and
its amenities.
This is just one example of a Lambda use case. With Lambda, you can run code for
virtually any application or backend service. Other Lambda use cases include:
• Automated backups
• Processing objects that are uploaded to Amazon S3
• Event-driven log analysis
• Event-driven transformations
• Internet of Things (IoT)
• Operating serverless websites
Other tools: Shell scripting
Shell scripting commands are run directly from the command line of an operating system. They are
available on any machine and on any operating system without the need to install new software.
Different environments require different syntax or types of shell scripting, such as Bash and Zshell.
zs
19
h
Bash logo – Copyright Free Software Foundation, licensed under the Free Art License. Designed by ProspectOne. Available at the Official GNU Bash Logo GitHub page.
Shell scripting versus Python
• Shell scripting can be a powerful tool for system administration and command-line work, but it can
be challenging when you want to use more complicated data structures.
• For example: Python can perform some actions—such as creating an HTTP server—in a single line.
However, it could require many lines of code to do the same action in Bash.
• Python has many external libraries and resources. It is a complete programming language.
Bash logo – Copyright Free Software Foundation, licensed under the Free Art License. Designed by ProspectOne. Available at the Official GNU Bash Logo GitHub page.
20
Checkpoint questions
Name at least two different IDEs that you can use to write Python code.
21
Answers:
1. Python uses an interpreter
2. Some examples of uses for shell scripts are:
• Alerting a system administrator about low disk space
• Moving log files into an archive directory
3. False
4. Integrated Development Environment
5. Eclipse, PyCharm, Spyder, Notepad++, others
• Python is a free, general-purpose programming
Key takeaways language. It has a simpler syntax compared to other
programming languages.
• Python can be written in any text editor if the
interpreter is also installed.
• An integrated development environment (IDE)
provides several advantages for writing code.
• Shell scripting is a powerful tool for administration.
When administration becomes complicated, Python
is generally preferred for such tasks.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
22
• Python can be written in any text editor if the interpreter is also installed.