Raspberry Pi Python

Preview:

DESCRIPTION

Controllers

Citation preview

Presented by:

Building Raspberry Pi Controllers with Python

July 7, 2015Don Wilcher

Class 2: Introduction to the Python Programming Language

Presented by:

Day 2 Agenda:• Concepts of the Python Programming Language• Review of the Python IDLE and shell• sudo Python IDLE and shell• Coding with Python using interpretive

programming • Building a simple calculator

2

Introduction to the Python Programming Language

Presented by:

3

Learning Objectives:• Learn about the Python Programming

Language• Learn about Python IDLE and shell• Learn about sudo Python IDLE and shell• Learn how to build simple Python

calculators

Introduction to the Python Programming Language

Presented by:

4

Concepts of the Python Programming LanguagePython is:

• An object oriented language• An interpretive programming

language• An easy to learn programming

language• A rapid prototyping tool for object

models and algorithms• A creative programming language for

creating games and graphics

Presented by:

5

Who created Python?• Guido Van Rossum (A Dutch Computer

Programming)• He created the language in 1986• He worked for Google from 2005 -2012• Started working for Dropbox in 2013

Concepts of the Python Programming Language…

Presented by:

6

What type of programming language is Python?

Python Question 1:

Presented by:

7

Why did Guido Van Rossum created Python?

• He was looking for a hobby programming language to keep him occupied during the Christmas season.

• He wanted code that is as understandable as plain English

• To teach programming in elementary and secondary schools (DARPA proposal: Computer Programming for Everyone

Concepts of the Python Programming Language…

Presented by:

8

Python Question 2:

Why did Guido Van Rossum created the Python programming language?

Presented by:

9

Review of Python IDLE and Shell

How to gain access to the Python Shell !

Presented by:

10

Review of Python IDLE and Shell…

The Python Shell allows you to test algorithms and code interactively!

Presented by:

11

Python Question 3

IDLE is the abbreviation for what Python development tool?

Presented by:

12

Review of Python IDLE and Shell…

Help is just 2-clicks away!

Presented by:

13

Online Help: Python Documentation

Review of Python IDLE and Shell…

Presented by:

14

vs

What’s different between the two versions?

http://learntocodewith.me/programming/python/python-2-vs-python-3/Source:

Presented by:

15

Python Question 4

What shell tool allows access to the Python Documentation?

Presented by:

16

Gaining access to sudo python

Presented by:

17

Gaining access to sudo python…

Presented by:

18

Interpretive Programming Example

Presented by:

19

Interpretive Programming: Let’s Build a Calculator

Lets build a Python Application (Calculator) using interpretive programming to find the voltage drop across a dc motor!

Problem:A dc motor’s resistance is equal to 4Ω. The current that flows through the resistor is 500mA. What is the voltage drop across the dc motor?Equation: Vmotor = Rmotor x Imotor

Presented by:

20

Interpretive Programming: Let’s Build a Calculator

Here’s the DC Motor Circuit for the Python Calculator Analysis!

Presented by:

21

Interpretive Programming: Let’s Build a Calculator…

Solution:Rmotor = 4ΩImotor = 250mAEquation: Vmotor = Imotor x RmotorVmotor = 250mA x4ΩVmotor = 1V

Presented by:

22

Interpretive Programming: Let’s Build a Calculator…

Solution:

Presented by:

23

Interpretive Programming: Let’s Build a Calculator…

The circuit analysis result value is less than the Python Calculator answer because of model component variations!

Presented by:

24

Python Question 5:

Why is there a slight difference in Imotor values between the Python calculation and the Microcap circuit model?

Recommended