24
Presented by: Building Raspberry Pi Controllers with Python July 7, 2015 Don Wilcher Class 2: Introduction to the Python Programming Language

Raspberry Pi Python

Embed Size (px)

DESCRIPTION

Controllers

Citation preview

Page 1: Raspberry Pi Python

Presented by:

Building Raspberry Pi Controllers with Python

July 7, 2015Don Wilcher

Class 2: Introduction to the Python Programming Language

Page 2: Raspberry Pi Python

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

Page 3: Raspberry Pi Python

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

Page 4: Raspberry Pi Python

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

Page 5: Raspberry Pi Python

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…

Page 6: Raspberry Pi Python

Presented by:

6

What type of programming language is Python?

Python Question 1:

Page 7: Raspberry Pi Python

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…

Page 8: Raspberry Pi Python

Presented by:

8

Python Question 2:

Why did Guido Van Rossum created the Python programming language?

Page 9: Raspberry Pi Python

Presented by:

9

Review of Python IDLE and Shell

How to gain access to the Python Shell !

Page 10: Raspberry Pi Python

Presented by:

10

Review of Python IDLE and Shell…

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

Page 11: Raspberry Pi Python

Presented by:

11

Python Question 3

IDLE is the abbreviation for what Python development tool?

Page 12: Raspberry Pi Python

Presented by:

12

Review of Python IDLE and Shell…

Help is just 2-clicks away!

Page 13: Raspberry Pi Python

Presented by:

13

Online Help: Python Documentation

Review of Python IDLE and Shell…

Page 14: Raspberry Pi Python

Presented by:

14

vs

What’s different between the two versions?

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

Page 15: Raspberry Pi Python

Presented by:

15

Python Question 4

What shell tool allows access to the Python Documentation?

Page 16: Raspberry Pi Python

Presented by:

16

Gaining access to sudo python

Page 17: Raspberry Pi Python

Presented by:

17

Gaining access to sudo python…

Page 18: Raspberry Pi Python

Presented by:

18

Interpretive Programming Example

Page 19: Raspberry Pi Python

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

Page 20: Raspberry Pi Python

Presented by:

20

Interpretive Programming: Let’s Build a Calculator

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

Page 21: Raspberry Pi Python

Presented by:

21

Interpretive Programming: Let’s Build a Calculator…

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

Page 22: Raspberry Pi Python

Presented by:

22

Interpretive Programming: Let’s Build a Calculator…

Solution:

Page 23: Raspberry Pi Python

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!

Page 24: Raspberry Pi Python

Presented by:

24

Python Question 5:

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