69
Pi Is For… Programming In Raspberry

Pi Is For Python

Embed Size (px)

Citation preview

Page 1: Pi Is For Python

Pi Is For…Programming

In

Raspberry

Page 2: Pi Is For Python

Computers Don’t Do Anything

Without Instructions

Page 3: Pi Is For Python

Programming, or Coding, is how we

tell computers what to do using

instructions that the computer understands.

Page 4: Pi Is For Python

What Is A Computer Interface?

Page 5: Pi Is For Python

Jacquard Loom Interface - 1801

Page 6: Pi Is For Python

Switch Computer Interface - ENIAC 1945

Page 7: Pi Is For Python

1950’s - 1960’s BusinessNo Command Line Interface

1990’s PersonalGraphical User Interface (GUI)

Command Line Computer Interface

1970’s PersonalCommand Line Interface Only

(Sometimes called Shell Or Console)

Page 8: Pi Is For Python

Python Uses A Command Line Interface?

Page 9: Pi Is For Python

ARM Cortex-A53 CPU

How Does Programming Work?

Page 10: Pi Is For Python

Hardware Specific, Very Fast But Very Difficult For Human

Comprehension. This Is The Language That The Computer Speaks.

ARM Cortex-A53 CPU

How Does Programming Work?

Page 11: Pi Is For Python

How Does Programming Work?

ARM Cortex-A53 CPU

Page 12: Pi Is For Python

Hardware Specific, Very Fast And Somewhat Comprehendible For People.

ARM Cortex-A53 CPU

How Does Programming Work?

Page 13: Pi Is For Python

ARM Cortex-A53 CPU

How Does Programming Work?

Page 14: Pi Is For Python

High Level Languages Are Considered Cross Platform and Comprehendible. To Maintain Speed They Compile An

Assembly Or Machine Language Version Of The Code Specifically

For The CPU.

ARM Cortex-A53 CPU

Quality Compilers Can Generate Quicker CodeC Often Used In Graphics and Operating Systems

How Does Programming Work?

Page 15: Pi Is For Python

ARM Cortex-A53 CPU

Quality Compilers Can Generate Quicker CodeC Often Used In Graphics and Operating Systems

How Does Programming Work?

Page 16: Pi Is For Python

ARM Cortex-A53 CPU

PYTHON BASIC

Dynamic high-level general-purpose scripting languages (such as Python and PERL) execute programs in real time using pre-compiled API’s or machine code. Their advantage is that programs can be be constructed from pre built blocks and combined into complex programs.

PERL

Software Intermediary

How Does Programming Work?

Page 17: Pi Is For Python

How Does Programming Work?

ARM Cortex-A53 CPU - Linux

PYTHON CODE

Python Virtual Machine

Bytecode

Page 18: Pi Is For Python

How Does Programming Work?PYTHON CODE

ARM Cortex-A53 CPU - Linux

Python Virtual Machine

AMD Athlon™ X4 CPU - Windows

Python Virtual Machine

Intel® Core™ i7 CPU - MAC OSX

Python Virtual Machine

Page 19: Pi Is For Python

Hello world! In Machine Code

Why Python?

Page 20: Pi Is For Python

Why Python?

Hello world! In Assembly Language

Page 21: Pi Is For Python

Why Python?

Hello world! In BASIC, C and Python

Page 22: Pi Is For Python

Why Python?● Python Is A General Purpose Language

○ Many computer devices○ Libraries for most applications.

● Large Standard Code Library○ Standard Library runs on Raspberry Pi or CRAY Supercomputer.

● Can Be Compiled To Machine Language○ Cython compiles Python code To C.

● Can Call C Code○ Python ctypes

● Clean code○ Employs indentation○ No {..code in here..} or <div>..or stuff in here..<\div>

● Libraries, Libraries, Libraries○ The secret power of Python○ 67,000 libraries (Jan 1, 2016)

Page 23: Pi Is For Python

Getting Started On Raspberry Pi● https://www.raspberrypi.org/documentation/usage/python/

○ RUNNING PYTHON ON A RASPBERRY PI○ INDENTATION○ VARIABLES○ COMMENTS○ LISTS○ ITERATION and RANGE○ CREATING/SAVING PYTHON FILES○ EXECUTING PYTHON FILES

Page 24: Pi Is For Python

Python Interactive Mode

Python ShellCommand Line Interface

Python Prompt>>>

Getting Started On Raspberry Pi

Page 25: Pi Is For Python

Python Interactive Mode

Getting Started On Raspberry Pi

Page 26: Pi Is For Python

Getting Started On Raspberry Pi

Python Interactive Mode

Page 27: Pi Is For Python

Getting Started On Raspberry Pi

Python Run Module

Page 28: Pi Is For Python

Getting Started On Raspberry Pi

Python Run Module

Page 29: Pi Is For Python

Getting Started On Raspberry Pi

Python Run Module

Page 30: Pi Is For Python

Getting Started On Raspberry Pi

Python Run Module

Page 31: Pi Is For Python

CODE

https://trinket.io

Programming In Python - Overview

Page 32: Pi Is For Python

CODERESULT

(CONSOLE OUTPUT)

https://trinket.io

Programming In Python - Overview

Page 33: Pi Is For Python

https://trinket.io/python/81bea2e14c

Python Sequence Code

Page 34: Pi Is For Python

https://trinket.io/python/81bea2e14c

Python Sequence Code

Page 35: Pi Is For Python

https://trinket.io/python/883c20b4a3

Python Functions Code

Page 36: Pi Is For Python

https://trinket.io/python/883c20b4a3

Python Functions Code

Page 37: Pi Is For Python

https://trinket.io/python/883c20b4a3

Python Functions Code

Page 38: Pi Is For Python

https://trinket.io/python/81bea2e14c

Python Functions Code

Page 39: Pi Is For Python

https://trinket.io/python/883c20b4a3

Python Functions Code

Page 40: Pi Is For Python

• Python runs as a minimum with always available “built-in libraries”.

• Libraries provide the code functionality

Python Built-In Libraries

Page 41: Pi Is For Python

https://trinket.io/python/df57cd9d6f

Python Import Standard Libraries

Page 42: Pi Is For Python

https://trinket.io/python/df57cd9d6f

Python Import Standard Libraries

Page 43: Pi Is For Python

Python Object Oriented Code

Page 44: Pi Is For Python

OBJECT

Python Object Oriented Code

Page 45: Pi Is For Python

OBJECT PROPERTIES

Python Object Oriented Code

Page 46: Pi Is For Python

Python Object Oriented Code

Page 47: Pi Is For Python

https://trinket.io/python/a9a6112ca5

Python Object Oriented Code

Page 48: Pi Is For Python

https://trinket.io/python/d4e0f1f07d

Python Object Oriented Code

Page 49: Pi Is For Python

Python “Clean” Code

Page 50: Pi Is For Python

Python “Clean” Code

Indentation and levels used as

separators in code. No curly

braces or containers.

Page 51: Pi Is For Python

Python “Clean” CodeMinimal use of colons, semi-colons, etc.

Page 52: Pi Is For Python

External Libraries - Wikipedia

The Beatles Wikipedia Page

Page 53: Pi Is For Python

External Libraries - Wikipedia

Packages Located In The Python Package Index (PyPI)

Page 54: Pi Is For Python

External Libraries - Wikipedia

Use Raspberry Pi Terminal To Install External Libraries Using PIP

Page 55: Pi Is For Python

External Libraries - Wikipedia

“sudo pip install wikipedia” In Terminal Installs The Python Wikipedia Library On Your Raspberry Pi

Page 56: Pi Is For Python

External Libraries - Wikipedia

Estimated 67,000 Libraries (Jan 1, 2016)

Page 57: Pi Is For Python

Review

Page 58: Pi Is For Python

ReviewPYTHON CODE

ARM Cortex-A53 CPU - Linux

Python Virtual Machine

AMD Athlon™ X4 CPU - Windows

Python Virtual Machine

Intel® Core™ i7 CPU - MAC OSX

Python Virtual Machine

Page 59: Pi Is For Python

Review

Page 60: Pi Is For Python

Review

Page 61: Pi Is For Python

Review

Page 62: Pi Is For Python

Review

Page 63: Pi Is For Python

Review

Page 64: Pi Is For Python

Review

Page 65: Pi Is For Python

Review

Page 66: Pi Is For Python

Review

Page 67: Pi Is For Python

Review

Page 68: Pi Is For Python

Review

Page 69: Pi Is For Python

Contact